65 unsigned ch = *aSequence;
74 const unsigned char* s = aSequence;
76 static const unsigned char utf8_len[] = {
89 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
90 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
91 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
92 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
93 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
94 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
95 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
96 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
99 int len = utf8_len[ *s - 0x80 ];
106 wxFAIL_MSG( wxS(
"uni_forward: invalid start byte" ) );
112 if( ( s[1] & 0xc0 ) != 0x80 )
115 wxFAIL_MSG( wxS(
"uni_forward: invalid continuation byte" ) );
120 ch = ((s[0] & 0x1f) << 6) +
121 ((s[1] & 0x3f) << 0);
127 if( (s[1] & 0xc0) != 0x80 ||
128 (s[2] & 0xc0) != 0x80 ||
129 (s[0] == 0xE0 && s[1] < 0xA0)
134 wxFAIL_MSG( wxS(
"uni_forward: invalid continuation byte" ) );
139 ch = ((s[0] & 0x0f) << 12) +
140 ((s[1] & 0x3f) << 6 ) +
141 ((s[2] & 0x3f) << 0 );
147 if( (s[1] & 0xc0) != 0x80 ||
148 (s[2] & 0xc0) != 0x80 ||
149 (s[3] & 0xc0) != 0x80 ||
150 (s[0] == 0xF0 && s[1] < 0x90) ||
151 (s[0] == 0xF4 && s[1] > 0x8F) )
154 wxFAIL_MSG( wxS(
"uni_forward: invalid continuation byte" ) );
159 ch = ((s[0] & 0x7) << 18) +
160 ((s[1] & 0x3f) << 12) +
161 ((s[2] & 0x3f) << 6 ) +
162 ((s[3] & 0x3f) << 0 );