diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-02-15 12:36:11 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-02-15 12:36:11 +0100 |
commit | 3210bc85ae1276350f18f4795efefe491c2206c2 (patch) | |
tree | 75c8d5831620cdc1d0c9145ca4579197e5cf0d94 /sal | |
parent | a0acad42105bc3f0304121a86f755958e38aeaac (diff) |
Rename rtl::isValidCodePoint -> rtl::isUnicodeCodePoint
...and fix its documentation, and use it throughout the code base.
Change-Id: I349bc2009b1b0aa7115ea90bc6ecd0a812f63698
Diffstat (limited to 'sal')
-rw-r--r-- | sal/rtl/uri.cxx | 8 | ||||
-rw-r--r-- | sal/rtl/ustrbuf.cxx | 4 | ||||
-rw-r--r-- | sal/rtl/ustring.cxx | 2 | ||||
-rw-r--r-- | sal/textenc/tcvtutf8.cxx | 2 | ||||
-rw-r--r-- | sal/textenc/unichars.hxx | 9 |
5 files changed, 14 insertions, 11 deletions
diff --git a/sal/rtl/uri.cxx b/sal/rtl/uri.cxx index b028b3cf6664..0f3d6df52194 100644 --- a/sal/rtl/uri.cxx +++ b/sal/rtl/uri.cxx @@ -132,8 +132,8 @@ sal_uInt32 readUcs4(sal_Unicode const ** pBegin, sal_Unicode const * pEnd, p += 3; nEncoded |= ((nWeight1 & 3) << 4 | nWeight2) << nShift; } - if (bUTF8 && nEncoded >= nMin && nEncoded <= 0x10FFFF - && !rtl::isHighSurrogate(nEncoded) + if (bUTF8 && rtl::isUnicodeCodePoint(nEncoded) + && nEncoded >= nMin && !rtl::isHighSurrogate(nEncoded) && !rtl::isLowSurrogate(nEncoded)) { *pBegin = p; @@ -213,7 +213,7 @@ sal_uInt32 readUcs4(sal_Unicode const ** pBegin, sal_Unicode const * pEnd, void writeUcs4(rtl_uString ** pBuffer, sal_Int32 * pCapacity, sal_uInt32 nUtf32) { - assert(nUtf32 <= 0x10FFFF); // bad UTF-32 char + assert(rtl::isUnicodeCodePoint(nUtf32)); if (nUtf32 <= 0xFFFF) { writeUnicode( pBuffer, pCapacity, static_cast< sal_Unicode >(nUtf32)); @@ -245,7 +245,7 @@ void writeEscapeOctet(rtl_uString ** pBuffer, sal_Int32 * pCapacity, bool writeEscapeChar(rtl_uString ** pBuffer, sal_Int32 * pCapacity, sal_uInt32 nUtf32, rtl_TextEncoding eCharset, bool bStrict) { - assert(nUtf32 <= 0x10FFFF); // bad UTF-32 char + assert(rtl::isUnicodeCodePoint(nUtf32)); if (eCharset == RTL_TEXTENCODING_UTF8) { if (nUtf32 < 0x80) writeEscapeOctet(pBuffer, pCapacity, nUtf32); diff --git a/sal/rtl/ustrbuf.cxx b/sal/rtl/ustrbuf.cxx index 89b897f21573..b73318b6e5f4 100644 --- a/sal/rtl/ustrbuf.cxx +++ b/sal/rtl/ustrbuf.cxx @@ -21,7 +21,7 @@ #include <osl/interlck.h> #include <osl/diagnose.h> - +#include <rtl/character.hxx> #include <rtl/ustrbuf.hxx> #include <strimp.hxx> @@ -169,7 +169,7 @@ void rtl_uStringbuffer_insertUtf32( { sal_Unicode buf[2]; sal_Int32 len; - OSL_ASSERT(c <= 0x10FFFF && !(c >= 0xD800 && c <= 0xDFFF)); + OSL_ASSERT(rtl::isUnicodeCodePoint(c) && !(c >= 0xD800 && c <= 0xDFFF)); if (c <= 0xFFFF) { buf[0] = (sal_Unicode) c; len = 1; diff --git a/sal/rtl/ustring.cxx b/sal/rtl/ustring.cxx index 16e9b87b6288..db07cabb396b 100644 --- a/sal/rtl/ustring.cxx +++ b/sal/rtl/ustring.cxx @@ -578,7 +578,7 @@ void SAL_CALL rtl_uString_newFromCodePoints( } n = codePointCount; for (i = 0; i < codePointCount; ++i) { - OSL_ASSERT(codePoints[i] <= 0x10FFFF); + OSL_ASSERT(rtl::isUnicodeCodePoint(codePoints[i])); if (codePoints[i] >= 0x10000) { ++n; } diff --git a/sal/textenc/tcvtutf8.cxx b/sal/textenc/tcvtutf8.cxx index 1f0b2bfc96ef..f9c9879c54a3 100644 --- a/sal/textenc/tcvtutf8.cxx +++ b/sal/textenc/tcvtutf8.cxx @@ -163,7 +163,7 @@ sal_Size ImplConvertUtf8ToUnicode( *pDestBufPtr++ = (sal_Unicode) nUtf32; else goto no_output; - else if (nUtf32 <= 0x10FFFF) + else if (rtl::isUnicodeCodePoint(nUtf32)) if (pDestBufEnd - pDestBufPtr >= 2) { *pDestBufPtr++ = (sal_Unicode) ImplGetHighSurrogate(nUtf32); diff --git a/sal/textenc/unichars.hxx b/sal/textenc/unichars.hxx index 09652b98ce57..0bcd6f710518 100644 --- a/sal/textenc/unichars.hxx +++ b/sal/textenc/unichars.hxx @@ -20,9 +20,12 @@ #ifndef INCLUDED_SAL_TEXTENC_UNICHARS_HXX #define INCLUDED_SAL_TEXTENC_UNICHARS_HXX -#include "sal/config.h" +#include <sal/config.h> + #include <cassert> -#include "sal/types.h" + +#include <rtl/character.hxx> +#include <sal/types.h> #define RTL_TEXTENC_UNICODE_REPLACEMENT_CHARACTER 0xFFFD @@ -30,7 +33,7 @@ inline bool ImplIsNoncharacter(sal_uInt32 nUtf32) { return (nUtf32 >= 0xFDD0 && nUtf32 <= 0xFDEF) || (nUtf32 & 0xFFFF) >= 0xFFFE - || nUtf32 > 0x10FFFF; + || !rtl::isUnicodeCodePoint(nUtf32); } // All code points that are noncharacters, as of Unicode 3.1.1. |