69 unsigned ch = *aSequence;
78 const unsigned char* s = aSequence;
80 static const unsigned char utf8_len[] = {
93 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
94 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
95 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
96 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
97 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
98 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
99 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
100 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
103 int len = utf8_len[ *s - 0x80 ];
110 wxFAIL_MSG( wxS(
"uni_forward: invalid start byte" ) );
116 if( ( s[1] & 0xc0 ) != 0x80 )
119 wxFAIL_MSG( wxS(
"uni_forward: invalid continuation byte" ) );
124 ch = ((s[0] & 0x1f) << 6) +
125 ((s[1] & 0x3f) << 0);
131 if( (s[1] & 0xc0) != 0x80 ||
132 (s[2] & 0xc0) != 0x80 ||
133 (s[0] == 0xE0 && s[1] < 0xA0)
138 wxFAIL_MSG( wxS(
"uni_forward: invalid continuation byte" ) );
143 ch = ((s[0] & 0x0f) << 12) +
144 ((s[1] & 0x3f) << 6 ) +
145 ((s[2] & 0x3f) << 0 );
151 if( (s[1] & 0xc0) != 0x80 ||
152 (s[2] & 0xc0) != 0x80 ||
153 (s[3] & 0xc0) != 0x80 ||
154 (s[0] == 0xF0 && s[1] < 0x90) ||
155 (s[0] == 0xF4 && s[1] > 0x8F) )
158 wxFAIL_MSG( wxS(
"uni_forward: invalid continuation byte" ) );
163 ch = ((s[0] & 0x7) << 18) +
164 ((s[1] & 0x3f) << 12) +
165 ((s[2] & 0x3f) << 6 ) +
166 ((s[3] & 0x3f) << 0 );