Subversion Repositories Kolibri OS

Rev

Rev 9715 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
7736 dunkaist 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
10051 ace_dent 3
;; Copyright (C) KolibriOS team 2020-2024. All rights reserved. ;;
7736 dunkaist 4
;;  Distributed under terms of the GNU General Public License.  ;;
5
;;      Version 2, or (at your option) any later version.       ;;
6
;;                                                              ;;
7
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8
 
9
 
10
unicode.utf8.decode:
11
        test    ecx, ecx
12
        jz      .error
13
        movzx   eax, byte[esi]
14
        test    al, al
15
        jns     .read1
16
        shl     al, 2
17
        jnc     .error
18
        shl     al, 1
19
        jnc     .read2
20
        shl     al, 1
21
        jnc     .read3
22
        shl     al, 1
23
        jnc     .read4
24
        jmp     .error
25
.read1:
26
        sub     ecx, 1
27
        add     esi, 1
28
        jmp     .done
29
.read2:
30
        cmp     ecx, 2
31
        jb      .error
32
        shl     eax, 5
33
        mov     al, [esi+1]
34
        shl     al, 1
35
        jnc     .error
36
        shl     al, 1
37
        jc      .error
38
        shr     eax, 2
39
        sub     ecx, 2
40
        add     esi, 2
41
        jmp     .done
42
.read3:
43
        cmp     ecx, 3
44
        jb      .error
45
        shl     eax, 4
46
        mov     al, [esi+1]
47
        shl     al, 1
48
        jnc     .error
49
        shl     al, 1
50
        jc      .error
51
        shl     eax, 6
52
        mov     al, [esi+2]
53
        shl     al, 1
54
        jnc     .error
55
        shl     al, 1
56
        jc      .error
57
        shr     eax, 2
58
        sub     ecx, 3
59
        add     esi, 3
60
        jmp     .done
61
.read4:
62
        cmp     ecx, 4
63
        jb      .error
64
        shl     eax, 3
65
        mov     al, [esi+1]
66
        shl     al, 1
67
        jnc     .error
68
        shl     al, 1
69
        jc      .error
70
        shl     eax, 6
71
        mov     al, [esi+2]
72
        shl     al, 1
73
        jnc     .error
74
        shl     al, 1
75
        jc      .error
76
        shl     eax, 6
77
        mov     al, [esi+3]
78
        shl     al, 1
79
        jnc     .error
80
        shl     al, 1
81
        jc      .error
82
        shr     eax, 2
83
        sub     ecx, 4
84
        add     esi, 4
85
        jmp     .done
86
.error:
87
.done:
88
        ret
89
 
90
 
91
unicode.cp866.encode:
92
        call    uni2ansi_char
93
        ret
94
 
95
 
96
unicode.utf16.encode:
97
        cmp     eax, 0x110000
98
        jae     .error
99
        cmp     eax, 0x10000
100
        jae     .write2
101
        cmp     eax, 0xe000
102
        jae     .write1
103
        cmp     eax, 0xd800
104
        jb      .write1
105
        jmp     .error
106
.write1:
107
        jmp     .done
108
.write2:
109
        sub     eax, 0x10000
110
        shl     eax, 6
111
        shr     ax, 6
112
        or      eax, 0xdc00d800
113
        jmp     .done
114
.done:
115
.error:
116
        ret