X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/51004dcb01e06fef634b61be77ed73dd61cb6db9..f3c0d7a59d99c2a94c6b8822291f0e42be3773c9:/icuSources/common/unicode/utf8.h diff --git a/icuSources/common/unicode/utf8.h b/icuSources/common/unicode/utf8.h index 21e5f3d0..18e7e945 100644 --- a/icuSources/common/unicode/utf8.h +++ b/icuSources/common/unicode/utf8.h @@ -1,12 +1,14 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /* ******************************************************************************* * -* Copyright (C) 1999-2013, International Business Machines +* Copyright (C) 1999-2015, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* * file name: utf8.h -* encoding: US-ASCII +* encoding: UTF-8 * tab size: 8 (not used) * indentation:4 * @@ -39,25 +41,7 @@ /* internal definitions ----------------------------------------------------- */ -/** - * \var utf8_countTrailBytes - * Internal array with numbers of trail bytes for any given byte used in - * lead byte position. - * - * This is internal since it is not meant to be called directly by external clients; - * however it is called by public macros in this file and thus must remain stable, - * and should not be hidden when other internal functions are hidden (otherwise - * public macros would fail to compile). - * @internal - */ -#ifdef U_UTF8_IMPL -U_EXPORT const uint8_t -#elif defined(U_STATIC_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) -U_CFUNC const uint8_t -#else -U_CFUNC U_IMPORT const uint8_t /* U_IMPORT2? */ /*U_IMPORT*/ -#endif -utf8_countTrailBytes[256]; + /** * Counts the trail bytes for a UTF-8 lead byte. @@ -78,9 +62,9 @@ utf8_countTrailBytes[256]; * @internal */ #define U8_COUNT_TRAIL_BYTES(leadByte) \ - ((leadByte)<0xf0 ? \ - ((leadByte)>=0xc0)+((leadByte)>=0xe0) : \ - (leadByte)<0xfe ? 3+((leadByte)>=0xf8)+((leadByte)>=0xfc) : 0) + ((uint8_t)(leadByte)<0xf0 ? \ + ((uint8_t)(leadByte)>=0xc0)+((uint8_t)(leadByte)>=0xe0) : \ + (uint8_t)(leadByte)<0xfe ? 3+((uint8_t)(leadByte)>=0xf8)+((uint8_t)(leadByte)>=0xfc) : 0) /** * Counts the trail bytes for a UTF-8 lead byte of a valid UTF-8 sequence. @@ -253,7 +237,6 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); U8_NEXT(s, _u8_get_index, length, c); \ } -#ifndef U_HIDE_DRAFT_API /** * Get a code point from a string at a random-access offset, * without changing the offset. @@ -277,14 +260,13 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @param length int32_t string length * @param c output UChar32 variable, set to U+FFFD in case of an error * @see U8_GET - * @draft ICU 51 + * @stable ICU 51 */ #define U8_GET_OR_FFFD(s, start, i, length, c) { \ int32_t _u8_get_index=(i); \ U8_SET_CP_START(s, start, _u8_get_index); \ U8_NEXT_OR_FFFD(s, _u8_get_index, length, c); \ } -#endif /* U_HIDE_DRAFT_API */ /* definitions with forward iteration --------------------------------------- */ @@ -368,7 +350,6 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); } \ } -#ifndef U_HIDE_DRAFT_API /** * Get a code point from a string at a code point boundary offset, * and advance the offset to the next code point boundary. @@ -391,7 +372,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @param length int32_t string length * @param c output UChar32 variable, set to U+FFFD in case of an error * @see U8_NEXT - * @draft ICU 51 + * @stable ICU 51 */ #define U8_NEXT_OR_FFFD(s, i, length, c) { \ (c)=(uint8_t)(s)[(i)++]; \ @@ -419,7 +400,6 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); } \ } \ } -#endif /* U_HIDE_DRAFT_API */ /** * Append a code point to a string, overwriting 1 to 4 bytes. @@ -676,7 +656,6 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); } \ } -#ifndef U_HIDE_DRAFT_API /** * Move the string offset from one code point boundary to the previous one * and get the code point between them. @@ -699,7 +678,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @param i int32_t string offset, must be start