50 #define U16_IS_SINGLE(c) !U_IS_SURROGATE(c)
58 #define U16_IS_LEAD(c) (((c)&0xfffffc00)==0xd800)
66 #define U16_IS_TRAIL(c) (((c)&0xfffffc00)==0xdc00)
74 #define U16_IS_SURROGATE(c) U_IS_SURROGATE(c)
83 #define U16_IS_SURROGATE_LEAD(c) (((c)&0x400)==0)
92 #define U16_IS_SURROGATE_TRAIL(c) (((c)&0x400)!=0)
98 #define U16_SURROGATE_OFFSET ((0xd800<<10UL)+0xdc00-0x10000)
111 #define U16_GET_SUPPLEMENTARY(lead, trail) \
112 (((UChar32)(lead)<<10UL)+(UChar32)(trail)-U16_SURROGATE_OFFSET)
122 #define U16_LEAD(supplementary) (UChar)(((supplementary)>>10)+0xd7c0)
131 #define U16_TRAIL(supplementary) (UChar)(((supplementary)&0x3ff)|0xdc00)
140 #define U16_LENGTH(c) ((uint32_t)(c)<=0xffff ? 1 : 2)
147 #define U16_MAX_LENGTH 2
166 #define U16_GET_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \
168 if(U16_IS_SURROGATE(c)) { \
169 if(U16_IS_SURROGATE_LEAD(c)) { \
170 (c)=U16_GET_SUPPLEMENTARY((c), (s)[(i)+1]); \
172 (c)=U16_GET_SUPPLEMENTARY((s)[(i)-1], (c)); \
175 } UPRV_BLOCK_MACRO_END
200 #define U16_GET(s, start, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \
202 if(U16_IS_SURROGATE(c)) { \
204 if(U16_IS_SURROGATE_LEAD(c)) { \
205 if((i)+1!=(length) && U16_IS_TRAIL(__c2=(s)[(i)+1])) { \
206 (c)=U16_GET_SUPPLEMENTARY((c), __c2); \
209 if((i)>(start) && U16_IS_LEAD(__c2=(s)[(i)-1])) { \
210 (c)=U16_GET_SUPPLEMENTARY(__c2, (c)); \
214 } UPRV_BLOCK_MACRO_END
239 #define U16_GET_OR_FFFD(s, start, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \
241 if(U16_IS_SURROGATE(c)) { \
243 if(U16_IS_SURROGATE_LEAD(c)) { \
244 if((i)+1!=(length) && U16_IS_TRAIL(__c2=(s)[(i)+1])) { \
245 (c)=U16_GET_SUPPLEMENTARY((c), __c2); \
250 if((i)>(start) && U16_IS_LEAD(__c2=(s)[(i)-1])) { \
251 (c)=U16_GET_SUPPLEMENTARY(__c2, (c)); \
257 } UPRV_BLOCK_MACRO_END
280 #define U16_NEXT_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \
282 if(U16_IS_LEAD(c)) { \
283 (c)=U16_GET_SUPPLEMENTARY((c), (s)[(i)++]); \
285 } UPRV_BLOCK_MACRO_END
308 #define U16_NEXT(s, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \
310 if(U16_IS_LEAD(c)) { \
312 if((i)!=(length) && U16_IS_TRAIL(__c2=(s)[(i)])) { \
314 (c)=U16_GET_SUPPLEMENTARY((c), __c2); \
317 } UPRV_BLOCK_MACRO_END
340 #define U16_NEXT_OR_FFFD(s, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \
342 if(U16_IS_SURROGATE(c)) { \
344 if(U16_IS_SURROGATE_LEAD(c) && (i)!=(length) && U16_IS_TRAIL(__c2=(s)[(i)])) { \
346 (c)=U16_GET_SUPPLEMENTARY((c), __c2); \
351 } UPRV_BLOCK_MACRO_END
366 #define U16_APPEND_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \
367 if((uint32_t)(c)<=0xffff) { \
368 (s)[(i)++]=(uint16_t)(c); \
370 (s)[(i)++]=(uint16_t)(((c)>>10)+0xd7c0); \
371 (s)[(i)++]=(uint16_t)(((c)&0x3ff)|0xdc00); \
373 } UPRV_BLOCK_MACRO_END
392 #define U16_APPEND(s, i, capacity, c, isError) UPRV_BLOCK_MACRO_BEGIN { \
393 if((uint32_t)(c)<=0xffff) { \
394 (s)[(i)++]=(uint16_t)(c); \
395 } else if((uint32_t)(c)<=0x10ffff && (i)+1<(capacity)) { \
396 (s)[(i)++]=(uint16_t)(((c)>>10)+0xd7c0); \
397 (s)[(i)++]=(uint16_t)(((c)&0x3ff)|0xdc00); \
401 } UPRV_BLOCK_MACRO_END
413 #define U16_FWD_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \
414 if(U16_IS_LEAD((s)[(i)++])) { \
417 } UPRV_BLOCK_MACRO_END
432 #define U16_FWD_1(s, i, length) UPRV_BLOCK_MACRO_BEGIN { \
433 if(U16_IS_LEAD((s)[(i)++]) && (i)!=(length) && U16_IS_TRAIL((s)[i])) { \
436 } UPRV_BLOCK_MACRO_END
450 #define U16_FWD_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \
453 U16_FWD_1_UNSAFE(s, i); \
456 } UPRV_BLOCK_MACRO_END
473 #define U16_FWD_N(s, i, length, n) UPRV_BLOCK_MACRO_BEGIN { \
475 while(__N>0 && ((i)<(length) || ((length)<0 && (s)[i]!=0))) { \
476 U16_FWD_1(s, i, length); \
479 } UPRV_BLOCK_MACRO_END
494 #define U16_SET_CP_START_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \
495 if(U16_IS_TRAIL((s)[i])) { \
498 } UPRV_BLOCK_MACRO_END
514 #define U16_SET_CP_START(s, start, i) UPRV_BLOCK_MACRO_BEGIN { \
515 if(U16_IS_TRAIL((s)[i]) && (i)>(start) && U16_IS_LEAD((s)[(i)-1])) { \
518 } UPRV_BLOCK_MACRO_END
542 #define U16_PREV_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \
544 if(U16_IS_TRAIL(c)) { \
545 (c)=U16_GET_SUPPLEMENTARY((s)[--(i)], (c)); \
547 } UPRV_BLOCK_MACRO_END
569 #define U16_PREV(s, start, i, c) UPRV_BLOCK_MACRO_BEGIN { \
571 if(U16_IS_TRAIL(c)) { \
573 if((i)>(start) && U16_IS_LEAD(__c2=(s)[(i)-1])) { \
575 (c)=U16_GET_SUPPLEMENTARY(__c2, (c)); \
578 } UPRV_BLOCK_MACRO_END
600 #define U16_PREV_OR_FFFD(s, start, i, c) UPRV_BLOCK_MACRO_BEGIN { \
602 if(U16_IS_SURROGATE(c)) { \
604 if(U16_IS_SURROGATE_TRAIL(c) && (i)>(start) && U16_IS_LEAD(__c2=(s)[(i)-1])) { \
606 (c)=U16_GET_SUPPLEMENTARY(__c2, (c)); \
611 } UPRV_BLOCK_MACRO_END
624 #define U16_BACK_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \
625 if(U16_IS_TRAIL((s)[--(i)])) { \
628 } UPRV_BLOCK_MACRO_END
642 #define U16_BACK_1(s, start, i) UPRV_BLOCK_MACRO_BEGIN { \
643 if(U16_IS_TRAIL((s)[--(i)]) && (i)>(start) && U16_IS_LEAD((s)[(i)-1])) { \
646 } UPRV_BLOCK_MACRO_END
661 #define U16_BACK_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \
664 U16_BACK_1_UNSAFE(s, i); \
667 } UPRV_BLOCK_MACRO_END
683 #define U16_BACK_N(s, start, i, n) UPRV_BLOCK_MACRO_BEGIN { \
685 while(__N>0 && (i)>(start)) { \
686 U16_BACK_1(s, start, i); \
689 } UPRV_BLOCK_MACRO_END
704 #define U16_SET_CP_LIMIT_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \
705 if(U16_IS_LEAD((s)[(i)-1])) { \
708 } UPRV_BLOCK_MACRO_END
727 #define U16_SET_CP_LIMIT(s, start, i, length) UPRV_BLOCK_MACRO_BEGIN { \
728 if((start)<(i) && ((i)<(length) || (length)<0) && U16_IS_LEAD((s)[(i)-1]) && U16_IS_TRAIL((s)[i])) { \
731 } UPRV_BLOCK_MACRO_END
Basic types and constants for UTF.