31 static inline FXbool isUTF8(FXchar c){
32 return (c&0xC0)!=0x80;
36 static inline FXbool leadUTF8(FXchar c){
37 return (c&0xC0)==0xC0;
41 static inline FXbool followUTF8(FXchar c){
42 return (c&0xC0)==0x80;
46 static inline FXbool seqUTF8(FXchar c){
47 return (c&0x80)==0x80;
51 static inline FXival lenUTF8(FXchar c){
52 return ((0xE5000000>>((c>>3)&0x1E))&3)+1;
56 static inline FXival wclen(
const FXchar *ptr){
61 static inline FXwchar wc(
const FXchar* ptr){
62 FXwchar w=(FXuchar)ptr[0];
63 if(0xC0<=w){ w = (w<<6) ^ (FXuchar)ptr[1] ^ 0x3080;
64 if(0x800<=w){ w = (w<<6) ^ (FXuchar)ptr[2] ^ 0x20080;
65 if(0x10000<=w){ w = (w<<6) ^ (FXuchar)ptr[3] ^ 0x400080; }}}
70 static inline FXwchar wc1(
const FXchar* ptr){
71 return (FXuchar)ptr[0];
75 static inline FXwchar wc2(
const FXchar* ptr){
76 return ((FXuchar)ptr[0]<<6)^((FXuchar)ptr[1])^0x3080;
80 static inline FXwchar wc3(
const FXchar* ptr){
81 return ((FXuchar)ptr[0]<<12)^((FXuchar)ptr[1]<<6)^((FXuchar)ptr[2])^0x0E2080;
85 static inline FXwchar wc4(
const FXchar* ptr){
86 return ((FXuchar)ptr[0]<<18)^((FXuchar)ptr[1]<<12)^((FXuchar)ptr[2]<<6)^((FXuchar)ptr[3])^0x3C82080;
90 static inline FXwchar wcnxt(
const FXchar*& ptr){
91 FXwchar w=(FXuchar)*ptr++;
92 if(0xC0<=w){ w = (w<<6) ^ (FXuchar)*ptr++ ^ 0x3080;
93 if(0x800<=w){ w = (w<<6) ^ (FXuchar)*ptr++ ^ 0x20080;
94 if(0x10000<=w){ w = (w<<6) ^ (FXuchar)*ptr++ ^ 0x400080; }}}
99 static inline FXwchar wcnxt(FXchar*& ptr){
100 FXwchar w=(FXuchar)*ptr++;
101 if(0xC0<=w){ w = (w<<6) ^ (FXuchar)*ptr++ ^ 0x3080;
102 if(0x800<=w){ w = (w<<6) ^ (FXuchar)*ptr++ ^ 0x20080;
103 if(0x10000<=w){ w = (w<<6) ^ (FXuchar)*ptr++ ^ 0x400080; }}}
108 static inline FXwchar wcprv(
const FXchar*& ptr){
109 FXwchar w=(FXuchar)*--ptr;
110 if(0x80<=w){ w = ((FXuchar)*--ptr<<6) ^ w ^ 0x3080;
111 if(0x1000<=w){ w = ((FXuchar)*--ptr<<12) ^ w ^ 0xE1000;
112 if(0x20000<=w){ w = ((FXuchar)*--ptr<<18) ^ w ^ 0x3C60000; }}}
117 static inline FXwchar wcprv(FXchar*& ptr){
118 FXwchar w=(FXuchar)*--ptr;
119 if(0x80<=w){ w = ((FXuchar)*--ptr<<6) ^ w ^ 0x3080;
120 if(0x1000<=w){ w = ((FXuchar)*--ptr<<12) ^ w ^ 0xE1000;
121 if(0x20000<=w){ w = ((FXuchar)*--ptr<<18) ^ w ^ 0x3C60000; }}}
126 static inline const FXchar* wcinc(
const FXchar* ptr){
127 return (isUTF8(*++ptr) || isUTF8(*++ptr) || isUTF8(*++ptr) || ++ptr), ptr;
131 static inline FXchar* wcinc(FXchar* ptr){
132 return (isUTF8(*++ptr) || isUTF8(*++ptr) || isUTF8(*++ptr) || ++ptr), ptr;
136 static inline const FXchar* wcdec(
const FXchar* ptr){
137 return (isUTF8(*--ptr) || isUTF8(*--ptr) || isUTF8(*--ptr) || --ptr), ptr;
141 static inline FXchar* wcdec(FXchar* ptr){
142 return (isUTF8(*--ptr) || isUTF8(*--ptr) || isUTF8(*--ptr) || --ptr), ptr;
146 static inline const FXchar* wcstart(
const FXchar* ptr){
147 return (isUTF8(*ptr) || isUTF8(*--ptr) || isUTF8(*--ptr) || --ptr), ptr;
151 static inline FXchar* wcstart(FXchar* ptr){
152 return (isUTF8(*ptr) || isUTF8(*--ptr) || isUTF8(*--ptr) || --ptr), ptr;
158 static inline FXbool isUTF16(FXnchar c){
159 return (c&0xFC00)!=0xDC00;
163 static inline FXbool leadUTF16(FXnchar c){
164 return (c&0xFC00)==0xD800;
168 static inline FXbool followUTF16(FXnchar c){
169 return (c&0xFC00)==0xDC00;
173 static inline FXbool seqUTF16(FXnchar c){
174 return (c&0xF800)==0xD800;
178 static inline FXival lenUTF16(FXnchar c){
179 return leadUTF16(c)+1;
183 static inline FXival wclen(
const FXnchar *ptr){
184 return lenUTF16(*ptr);
188 static inline FXwchar wc(
const FXnchar* ptr){
190 if(leadUTF16(w)){ w = (w<<10) + ptr[1] - 0x35FDC00; }
195 static inline FXwchar wc1(
const FXnchar* ptr){
200 static inline FXwchar wc2(
const FXnchar* ptr){
201 return (ptr[0]<<10)+ptr[1]-0x35FDC00;
205 static inline FXwchar wcnxt(
const FXnchar*& ptr){
207 if(leadUTF16(w)){ w = (w<<10) + *ptr++ - 0x35FDC00; }
212 static inline FXwchar wcnxt(FXnchar*& ptr){
214 if(leadUTF16(w)){ w = (w<<10) + *ptr++ - 0x35FDC00; }
219 static inline FXwchar wcprv(
const FXnchar*& ptr){
221 if(followUTF16(w)){ w = (*--ptr<<10) + w - 0x35FDC00; }
226 static inline FXwchar wcprv(FXnchar*& ptr){
228 if(followUTF16(w)){ w = (*--ptr<<10) + w - 0x35FDC00; }
233 static inline const FXnchar* wcinc(
const FXnchar* ptr){
234 return (isUTF16(*++ptr) || ++ptr), ptr;
238 static inline FXnchar* wcinc(FXnchar* ptr){
239 return (isUTF16(*++ptr) || ++ptr), ptr;
243 static inline const FXnchar* wcdec(
const FXnchar* ptr){
244 return (isUTF16(*--ptr) || --ptr), ptr;
248 static inline FXnchar* wcdec(FXnchar* ptr){
249 return (isUTF16(*--ptr) || --ptr), ptr;
253 static inline const FXnchar* wcstart(
const FXnchar *ptr){
254 return (isUTF16(*ptr) || --ptr), ptr;
258 static inline FXnchar* wcstart(FXnchar *ptr){
259 return (isUTF16(*ptr) || --ptr), ptr;
263 static inline FXbool isUTF32(FXwchar c){
270 static inline FXival wc2utf(FXwchar w){
return 1+(0x80<=w)+(0x800<=w)+(0x10000<=w); }
273 static inline FXival wc2nc(FXwchar w){
return 1+(0x10000<=w); }
276 extern FXAPI FXival wcs2utf(
const FXwchar* src,FXival srclen);
277 extern FXAPI FXival wcs2utf(
const FXwchar* src);
280 extern FXAPI FXival ncs2utf(
const FXnchar* src,FXival srclen);
281 extern FXAPI FXival ncs2utf(
const FXnchar* src);
284 extern FXAPI FXival utf2wcs(
const FXchar src,FXival srclen);
285 extern FXAPI FXival utf2wcs(
const FXchar *src);
288 extern FXAPI FXival utf2ncs(
const FXchar *src,FXival srclen);
289 extern FXAPI FXival utf2ncs(
const FXchar *src);
295 extern FXAPI FXival wc2utf(FXchar *dst,FXwchar w);
298 extern FXAPI FXival wc2nc(FXnchar *dst,FXwchar w);
301 extern FXAPI FXival wcs2utf(FXchar *dst,
const FXwchar* src,FXival dstlen,FXival srclen);
302 extern FXAPI FXival wcs2utf(FXchar *dst,
const FXwchar* src,FXival dstlen);
305 extern FXAPI FXival ncs2utf(FXchar *dst,
const FXnchar* src,FXival dstlen,FXival srclen);
306 extern FXAPI FXival ncs2utf(FXchar *dst,
const FXnchar* src,FXival dstlen);
309 extern FXAPI FXival utf2wcs(FXwchar *dst,
const FXchar* src,FXival dstlen,FXival srclen);
310 extern FXAPI FXival utf2wcs(FXwchar *dst,
const FXchar* src,FXival dstlen);
313 extern FXAPI FXival utf2ncs(FXnchar *dst,
const FXchar* src,FXival dstlen,FXival srclen);
314 extern FXAPI FXival utf2ncs(FXnchar *dst,
const FXchar* src,FXival dstlen);
Definition: FX4Splitter.h:28