summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-09-13 13:35:49 +0200
committerStephan Bergmann <sbergman@redhat.com>2017-09-13 13:35:49 +0200
commit3f0fba004badec01e536ca0fe2889e7e0bb93d7a (patch)
treecdf682e89f56c29fd6a8cd650bdb8bba42eca555 /sal
parent2d22b39fb7ddbb02f246e2943b228931e5d583e1 (diff)
New rtl::isUnicodeScalarValue, rtl::isSurrogate
There are apparently various places that want to check for a Unicode scalar value rather than for a Unicode code point. Changed those uses of rtl::isUnicodeCodePoint where that was obvious. (For changing svtools/source/svrtf/svparser.cxx see 8e0fb74dc01927b60d8b868548ef8fe1d7a80ce3 "Revert 'svtools: HTML import: don't put lone surrogates in OUString'".) Other uses of rtl::isUnicodeCodePoint might also want to use rtl::isUnicodeScalarValue instead. As a side effect, this change also introduces rtl::isSurrogate, which is useful in a few places as well. Change-Id: I9245f4f98b83877145a4d392f0ddb7c5d824a535
Diffstat (limited to 'sal')
-rw-r--r--sal/rtl/uri.cxx5
-rw-r--r--sal/rtl/ustrbuf.cxx2
-rw-r--r--sal/textenc/tcvtutf8.cxx5
3 files changed, 4 insertions, 8 deletions
diff --git a/sal/rtl/uri.cxx b/sal/rtl/uri.cxx
index 257a0a27abac..57a7102a38eb 100644
--- a/sal/rtl/uri.cxx
+++ b/sal/rtl/uri.cxx
@@ -133,9 +133,8 @@ sal_uInt32 readUcs4(sal_Unicode const ** pBegin, sal_Unicode const * pEnd,
p += 3;
nEncoded |= ((nWeight1 & 3) << 4 | nWeight2) << nShift;
}
- if (bUTF8 && rtl::isUnicodeCodePoint(nEncoded)
- && nEncoded >= nMin && !rtl::isHighSurrogate(nEncoded)
- && !rtl::isLowSurrogate(nEncoded))
+ if (bUTF8 && rtl::isUnicodeScalarValue(nEncoded)
+ && nEncoded >= nMin)
{
*pBegin = p;
*pType = EscapeChar;
diff --git a/sal/rtl/ustrbuf.cxx b/sal/rtl/ustrbuf.cxx
index cef31a5da2ea..508c8d7a9c7c 100644
--- a/sal/rtl/ustrbuf.cxx
+++ b/sal/rtl/ustrbuf.cxx
@@ -168,7 +168,7 @@ void rtl_uStringbuffer_insertUtf32(
{
sal_Unicode buf[2];
sal_Int32 len;
- OSL_ASSERT(rtl::isUnicodeCodePoint(c) && !(c >= 0xD800 && c <= 0xDFFF));
+ OSL_ASSERT(rtl::isUnicodeScalarValue(c));
if (c <= 0xFFFF) {
buf[0] = (sal_Unicode) c;
len = 1;
diff --git a/sal/textenc/tcvtutf8.cxx b/sal/textenc/tcvtutf8.cxx
index d9c3c134a83a..f5ed9dfb995c 100644
--- a/sal/textenc/tcvtutf8.cxx
+++ b/sal/textenc/tcvtutf8.cxx
@@ -170,10 +170,7 @@ sal_Size ImplConvertUtf8ToUnicode(
}
break;
case 3:
- if (nUtf32 < 0x800
- || (!bJavaUtf8
- && (rtl::isHighSurrogate(nUtf32)
- || rtl::isLowSurrogate(nUtf32))))
+ if (nUtf32 < 0x800 || (!bJavaUtf8 && rtl::isSurrogate(nUtf32)))
{
goto bad_input;
}