51#define U16_IS_SINGLE(c) !U_IS_SURROGATE(c)
59#define U16_IS_LEAD(c) (((c)&0xfffffc00)==0xd800)
67#define U16_IS_TRAIL(c) (((c)&0xfffffc00)==0xdc00)
75#define U16_IS_SURROGATE(c) U_IS_SURROGATE(c)
84#define U16_IS_SURROGATE_LEAD(c) (((c)&0x400)==0)
93#define U16_IS_SURROGATE_TRAIL(c) (((c)&0x400)!=0)
99#define U16_SURROGATE_OFFSET ((0xd800<<10UL)+0xdc00-0x10000)
112#define U16_GET_SUPPLEMENTARY(lead, trail) \
113 (((UChar32)(lead)<<10UL)+(UChar32)(trail)-U16_SURROGATE_OFFSET)
123#define U16_LEAD(supplementary) (UChar)(((supplementary)>>10)+0xd7c0)
132#define U16_TRAIL(supplementary) (UChar)(((supplementary)&0x3ff)|0xdc00)
141#define U16_LENGTH(c) ((uint32_t)(c)<=0xffff ? 1 : 2)
148#define U16_MAX_LENGTH 2
167#define U16_GET_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \
169 if(U16_IS_SURROGATE(c)) { \
170 if(U16_IS_SURROGATE_LEAD(c)) { \
171 (c)=U16_GET_SUPPLEMENTARY((c), (s)[(i)+1]); \
173 (c)=U16_GET_SUPPLEMENTARY((s)[(i)-1], (c)); \
176} UPRV_BLOCK_MACRO_END
201#define U16_GET(s, start, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \
203 if(U16_IS_SURROGATE(c)) { \
205 if(U16_IS_SURROGATE_LEAD(c)) { \
206 if((i)+1!=(length) && U16_IS_TRAIL(__c2=(s)[(i)+1])) { \
207 (c)=U16_GET_SUPPLEMENTARY((c), __c2); \
210 if((i)>(start) && U16_IS_LEAD(__c2=(s)[(i)-1])) { \
211 (c)=U16_GET_SUPPLEMENTARY(__c2, (c)); \
215} UPRV_BLOCK_MACRO_END
240#define U16_GET_OR_FFFD(s, start, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \
242 if(U16_IS_SURROGATE(c)) { \
244 if(U16_IS_SURROGATE_LEAD(c)) { \
245 if((i)+1!=(length) && U16_IS_TRAIL(__c2=(s)[(i)+1])) { \
246 (c)=U16_GET_SUPPLEMENTARY((c), __c2); \
251 if((i)>(start) && U16_IS_LEAD(__c2=(s)[(i)-1])) { \
252 (c)=U16_GET_SUPPLEMENTARY(__c2, (c)); \
258} UPRV_BLOCK_MACRO_END
281#define U16_NEXT_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \
283 if(U16_IS_LEAD(c)) { \
284 (c)=U16_GET_SUPPLEMENTARY((c), (s)[(i)++]); \
286} UPRV_BLOCK_MACRO_END
309#define U16_NEXT(s, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \
311 if(U16_IS_LEAD(c)) { \
313 if((i)!=(length) && U16_IS_TRAIL(__c2=(s)[(i)])) { \
315 (c)=U16_GET_SUPPLEMENTARY((c), __c2); \
318} UPRV_BLOCK_MACRO_END
341#define U16_NEXT_OR_FFFD(s, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \
343 if(U16_IS_SURROGATE(c)) { \
345 if(U16_IS_SURROGATE_LEAD(c) && (i)!=(length) && U16_IS_TRAIL(__c2=(s)[(i)])) { \
347 (c)=U16_GET_SUPPLEMENTARY((c), __c2); \
352} UPRV_BLOCK_MACRO_END
367#define U16_APPEND_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \
368 if((uint32_t)(c)<=0xffff) { \
369 (s)[(i)++]=(uint16_t)(c); \
371 (s)[(i)++]=(uint16_t)(((c)>>10)+0xd7c0); \
372 (s)[(i)++]=(uint16_t)(((c)&0x3ff)|0xdc00); \
374} UPRV_BLOCK_MACRO_END
393#define U16_APPEND(s, i, capacity, c, isError) UPRV_BLOCK_MACRO_BEGIN { \
394 if((uint32_t)(c)<=0xffff) { \
395 (s)[(i)++]=(uint16_t)(c); \
396 } else if((uint32_t)(c)<=0x10ffff && (i)+1<(capacity)) { \
397 (s)[(i)++]=(uint16_t)(((c)>>10)+0xd7c0); \
398 (s)[(i)++]=(uint16_t)(((c)&0x3ff)|0xdc00); \
402} UPRV_BLOCK_MACRO_END
414#define U16_FWD_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \
415 if(U16_IS_LEAD((s)[(i)++])) { \
418} UPRV_BLOCK_MACRO_END
433#define U16_FWD_1(s, i, length) UPRV_BLOCK_MACRO_BEGIN { \
434 if(U16_IS_LEAD((s)[(i)++]) && (i)!=(length) && U16_IS_TRAIL((s)[i])) { \
437} UPRV_BLOCK_MACRO_END
451#define U16_FWD_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \
454 U16_FWD_1_UNSAFE(s, i); \
457} UPRV_BLOCK_MACRO_END
474#define U16_FWD_N(s, i, length, n) UPRV_BLOCK_MACRO_BEGIN { \
476 while(__N>0 && ((i)<(length) || ((length)<0 && (s)[i]!=0))) { \
477 U16_FWD_1(s, i, length); \
480} UPRV_BLOCK_MACRO_END
495#define U16_SET_CP_START_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \
496 if(U16_IS_TRAIL((s)[i])) { \
499} UPRV_BLOCK_MACRO_END
515#define U16_SET_CP_START(s, start, i) UPRV_BLOCK_MACRO_BEGIN { \
516 if(U16_IS_TRAIL((s)[i]) && (i)>(start) && U16_IS_LEAD((s)[(i)-1])) { \
519} UPRV_BLOCK_MACRO_END
543#define U16_PREV_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \
545 if(U16_IS_TRAIL(c)) { \
546 (c)=U16_GET_SUPPLEMENTARY((s)[--(i)], (c)); \
548} UPRV_BLOCK_MACRO_END
570#define U16_PREV(s, start, i, c) UPRV_BLOCK_MACRO_BEGIN { \
572 if(U16_IS_TRAIL(c)) { \
574 if((i)>(start) && U16_IS_LEAD(__c2=(s)[(i)-1])) { \
576 (c)=U16_GET_SUPPLEMENTARY(__c2, (c)); \
579} UPRV_BLOCK_MACRO_END
601#define U16_PREV_OR_FFFD(s, start, i, c) UPRV_BLOCK_MACRO_BEGIN { \
603 if(U16_IS_SURROGATE(c)) { \
605 if(U16_IS_SURROGATE_TRAIL(c) && (i)>(start) && U16_IS_LEAD(__c2=(s)[(i)-1])) { \
607 (c)=U16_GET_SUPPLEMENTARY(__c2, (c)); \
612} UPRV_BLOCK_MACRO_END
625#define U16_BACK_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \
626 if(U16_IS_TRAIL((s)[--(i)])) { \
629} UPRV_BLOCK_MACRO_END
643#define U16_BACK_1(s, start, i) UPRV_BLOCK_MACRO_BEGIN { \
644 if(U16_IS_TRAIL((s)[--(i)]) && (i)>(start) && U16_IS_LEAD((s)[(i)-1])) { \
647} UPRV_BLOCK_MACRO_END
662#define U16_BACK_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \
665 U16_BACK_1_UNSAFE(s, i); \
668} UPRV_BLOCK_MACRO_END
684#define U16_BACK_N(s, start, i, n) UPRV_BLOCK_MACRO_BEGIN { \
686 while(__N>0 && (i)>(start)) { \
687 U16_BACK_1(s, start, i); \
690} UPRV_BLOCK_MACRO_END
705#define U16_SET_CP_LIMIT_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \
706 if(U16_IS_LEAD((s)[(i)-1])) { \
709} UPRV_BLOCK_MACRO_END
728#define U16_SET_CP_LIMIT(s, start, i, length) UPRV_BLOCK_MACRO_BEGIN { \
729 if((start)<(i) && ((i)<(length) || (length)<0) && U16_IS_LEAD((s)[(i)-1]) && U16_IS_TRAIL((s)[i])) { \
732} UPRV_BLOCK_MACRO_END
Basic types and constants for UTF.
C API: Code point macros.