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) { \ 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)); \ 200 #define U16_GET(s, start, i, length, c) { \ 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)); \ 239 #define U16_GET_OR_FFFD(s, start, i, length, c) { \ 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)); \ 280 #define U16_NEXT_UNSAFE(s, i, c) { \ 282 if(U16_IS_LEAD(c)) { \ 283 (c)=U16_GET_SUPPLEMENTARY((c), (s)[(i)++]); \ 308 #define U16_NEXT(s, i, length, c) { \ 310 if(U16_IS_LEAD(c)) { \ 312 if((i)!=(length) && U16_IS_TRAIL(__c2=(s)[(i)])) { \ 314 (c)=U16_GET_SUPPLEMENTARY((c), __c2); \ 340 #define U16_NEXT_OR_FFFD(s, i, length, c) { \ 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); \ 366 #define U16_APPEND_UNSAFE(s, i, c) { \ 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); \ 392 #define U16_APPEND(s, i, capacity, c, isError) { \ 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); \ 413 #define U16_FWD_1_UNSAFE(s, i) { \ 414 if(U16_IS_LEAD((s)[(i)++])) { \ 432 #define U16_FWD_1(s, i, length) { \ 433 if(U16_IS_LEAD((s)[(i)++]) && (i)!=(length) && U16_IS_TRAIL((s)[i])) { \ 450 #define U16_FWD_N_UNSAFE(s, i, n) { \ 453 U16_FWD_1_UNSAFE(s, i); \ 473 #define U16_FWD_N(s, i, length, n) { \ 475 while(__N>0 && ((i)<(length) || ((length)<0 && (s)[i]!=0))) { \ 476 U16_FWD_1(s, i, length); \ 494 #define U16_SET_CP_START_UNSAFE(s, i) { \ 495 if(U16_IS_TRAIL((s)[i])) { \ 514 #define U16_SET_CP_START(s, start, i) { \ 515 if(U16_IS_TRAIL((s)[i]) && (i)>(start) && U16_IS_LEAD((s)[(i)-1])) { \ 542 #define U16_PREV_UNSAFE(s, i, c) { \ 544 if(U16_IS_TRAIL(c)) { \ 545 (c)=U16_GET_SUPPLEMENTARY((s)[--(i)], (c)); \ 569 #define U16_PREV(s, start, i, c) { \ 571 if(U16_IS_TRAIL(c)) { \ 573 if((i)>(start) && U16_IS_LEAD(__c2=(s)[(i)-1])) { \ 575 (c)=U16_GET_SUPPLEMENTARY(__c2, (c)); \ 600 #define U16_PREV_OR_FFFD(s, start, i, c) { \ 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)); \ 624 #define U16_BACK_1_UNSAFE(s, i) { \ 625 if(U16_IS_TRAIL((s)[--(i)])) { \ 642 #define U16_BACK_1(s, start, i) { \ 643 if(U16_IS_TRAIL((s)[--(i)]) && (i)>(start) && U16_IS_LEAD((s)[(i)-1])) { \ 661 #define U16_BACK_N_UNSAFE(s, i, n) { \ 664 U16_BACK_1_UNSAFE(s, i); \ 683 #define U16_BACK_N(s, start, i, n) { \ 685 while(__N>0 && (i)>(start)) { \ 686 U16_BACK_1(s, start, i); \ 704 #define U16_SET_CP_LIMIT_UNSAFE(s, i) { \ 705 if(U16_IS_LEAD((s)[(i)-1])) { \ 727 #define U16_SET_CP_LIMIT(s, start, i, length) { \ 728 if((start)<(i) && ((i)<(length) || (length)<0) && U16_IS_LEAD((s)[(i)-1]) && U16_IS_TRAIL((s)[i])) { \ Basic types and constants for UTF.
C API: Code point macros.