Subversion Repositories Kolibri OS

Rev

Rev 7736 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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