X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/b75a7d8f3b4adbae880cab104ce2c6a50eee4db2..729e4ab9bc6618bc3d8a898e575df7f4019e29ca:/icuSources/common/unicode/utf16.h?ds=inline diff --git a/icuSources/common/unicode/utf16.h b/icuSources/common/unicode/utf16.h index eb3f5dde..5079c114 100644 --- a/icuSources/common/unicode/utf16.h +++ b/icuSources/common/unicode/utf16.h @@ -1,7 +1,7 @@ /* ******************************************************************************* * -* Copyright (C) 1999-2001, International Business Machines +* Copyright (C) 1999-2010, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -23,7 +23,7 @@ * and some common definitions. * * For more information see utf.h and the ICU User Guide Strings chapter - * (http://oss.software.ibm.com/icu/userguide/). + * (http://icu-project.org/userguide/strings.html). * * Usage: * ICU coding guidelines for if() statements should be followed when using these macros. @@ -31,21 +31,21 @@ * bodies and all macro statements should be terminated with semicolon. */ +#ifndef __UTF16_H__ +#define __UTF16_H__ + /* utf.h must be included first. */ #ifndef __UTF_H__ # include "unicode/utf.h" #endif -#ifndef __UTF16_H__ -#define __UTF16_H__ - /* single-code point definitions -------------------------------------------- */ /** * Does this code unit alone encode a code point (BMP, not a surrogate)? * @param c 16-bit code unit * @return TRUE or FALSE - * @draft ICU 2.4 + * @stable ICU 2.4 */ #define U16_IS_SINGLE(c) !U_IS_SURROGATE(c) @@ -53,7 +53,7 @@ * Is this code unit a lead surrogate (U+d800..U+dbff)? * @param c 16-bit code unit * @return TRUE or FALSE - * @draft ICU 2.4 + * @stable ICU 2.4 */ #define U16_IS_LEAD(c) (((c)&0xfffffc00)==0xd800) @@ -61,7 +61,7 @@ * Is this code unit a trail surrogate (U+dc00..U+dfff)? * @param c 16-bit code unit * @return TRUE or FALSE - * @draft ICU 2.4 + * @stable ICU 2.4 */ #define U16_IS_TRAIL(c) (((c)&0xfffffc00)==0xdc00) @@ -69,7 +69,7 @@ * Is this code unit a surrogate (U+d800..U+dfff)? * @param c 16-bit code unit * @return TRUE or FALSE - * @draft ICU 2.4 + * @stable ICU 2.4 */ #define U16_IS_SURROGATE(c) U_IS_SURROGATE(c) @@ -78,10 +78,19 @@ * is it a lead surrogate? * @param c 16-bit code unit * @return TRUE or FALSE - * @draft ICU 2.4 + * @stable ICU 2.4 */ #define U16_IS_SURROGATE_LEAD(c) (((c)&0x400)==0) +/** + * Assuming c is a surrogate code point (U16_IS_SURROGATE(c)), + * is it a trail surrogate? + * @param c 16-bit code unit + * @return TRUE or FALSE + * @stable ICU 4.2 + */ +#define U16_IS_SURROGATE_TRAIL(c) (((c)&0x400)!=0) + /** * Helper constant for U16_GET_SUPPLEMENTARY. * @internal @@ -97,10 +106,10 @@ * @param lead lead surrogate (U+d800..U+dbff) * @param trail trail surrogate (U+dc00..U+dfff) * @return supplementary code point (U+10000..U+10ffff) - * @draft ICU 2.4 + * @stable ICU 2.4 */ #define U16_GET_SUPPLEMENTARY(lead, trail) \ - (((lead)<<10UL)+(trail)-U16_SURROGATE_OFFSET) + (((UChar32)(lead)<<10UL)+(UChar32)(trail)-U16_SURROGATE_OFFSET) /** @@ -108,7 +117,7 @@ * supplementary code point (0x10000..0x10ffff). * @param supplementary 32-bit code point (U+10000..U+10ffff) * @return lead surrogate (U+d800..U+dbff) for supplementary - * @draft ICU 2.4 + * @stable ICU 2.4 */ #define U16_LEAD(supplementary) (UChar)(((supplementary)>>10)+0xd7c0) @@ -117,7 +126,7 @@ * supplementary code point (0x10000..0x10ffff). * @param supplementary 32-bit code point (U+10000..U+10ffff) * @return trail surrogate (U+dc00..U+dfff) for supplementary - * @draft ICU 2.4 + * @stable ICU 2.4 */ #define U16_TRAIL(supplementary) (UChar)(((supplementary)&0x3ff)|0xdc00) @@ -126,14 +135,14 @@ * The result is not defined if c is not a Unicode code point (U+0000..U+10ffff). * @param c 32-bit code point * @return 1 or 2 - * @draft ICU 2.4 + * @stable ICU 2.4 */ #define U16_LENGTH(c) ((uint32_t)(c)<=0xffff ? 1 : 2) /** * The maximum number of 16-bit code units per Unicode code point (U+0000..U+10ffff). * @return 2 - * @draft ICU 2.4 + * @stable ICU 2.4 */ #define U16_MAX_LENGTH 2 @@ -152,7 +161,7 @@ * @param i string offset * @param c output UChar32 variable * @see U16_GET - * @draft ICU 2.4 + * @stable ICU 2.4 */ #define U16_GET_UNSAFE(s, i, c) { \ (c)=(s)[i]; \ @@ -179,11 +188,11 @@ * * @param s const UChar * string * @param start starting string offset (usually 0) - * @param i string offset, start<=i=(start) && U16_IS_LEAD(__c2=(s)[(i)-1])) { \ + if((i)>(start) && U16_IS_LEAD(__c2=(s)[(i)-1])) { \ (c)=U16_GET_SUPPLEMENTARY(__c2, (c)); \ } \ } \ @@ -220,7 +229,7 @@ * @param i string offset * @param c output UChar32 variable * @see U16_NEXT - * @draft ICU 2.4 + * @stable ICU 2.4 */ #define U16_NEXT_UNSAFE(s, i, c) { \ (c)=(s)[(i)++]; \ @@ -243,11 +252,11 @@ * will be returned as the code point. * * @param s const UChar * string - * @param i string offset, i(start) && U16_IS_LEAD((s)[(i)-1])) { \ @@ -443,7 +452,7 @@ * @param i string offset * @param c output UChar32 variable * @see U16_PREV - * @draft ICU 2.4 + * @stable ICU 2.4 */ #define U16_PREV_UNSAFE(s, i, c) { \ (c)=(s)[--(i)]; \ @@ -468,10 +477,10 @@ * * @param s const UChar * string * @param start starting string offset (usually 0) - * @param i string offset, start<=i + * @param i string offset, must be start(start) && U16_IS_LEAD((s)[(i)-1])) { \ @@ -530,7 +539,7 @@ * @param i string offset * @param n number of code points to skip * @see U16_BACK_N - * @draft ICU 2.4 + * @stable ICU 2.4 */ #define U16_BACK_N_UNSAFE(s, i, n) { \ int32_t __N=(n); \ @@ -549,10 +558,10 @@ * * @param s const UChar * string * @param start start of string - * @param i string offset, i