summaryrefslogtreecommitdiff
path: root/include/rtl
diff options
context:
space:
mode:
Diffstat (limited to 'include/rtl')
-rw-r--r--include/rtl/character.hxx27
1 files changed, 27 insertions, 0 deletions
diff --git a/include/rtl/character.hxx b/include/rtl/character.hxx
index b83121a4a6d4..ee26f4ae1f9a 100644
--- a/include/rtl/character.hxx
+++ b/include/rtl/character.hxx
@@ -335,6 +335,20 @@ sal_uInt32 const surrogatesLowLast = 0xDFFF;
}
/// @endcond
+/** Check for surrogate.
+
+ @param code A Unicode code point.
+
+ @return True if code is a surrogate code point (0xD800--0xDFFF).
+
+ @since LibreOffice 6.0
+*/
+inline bool isSurrogate(sal_uInt32 code) {
+ assert(isUnicodeCodePoint(code));
+ return code >= detail::surrogatesHighFirst
+ && code <= detail::surrogatesLowLast;
+}
+
/** Check for high surrogate.
@param code A Unicode code point.
@@ -433,6 +447,19 @@ inline std::size_t splitSurrogates(sal_uInt32 code, sal_Unicode * output) {
}
}
+/** Check for Unicode scalar value.
+
+ @param code An integer.
+
+ @return True if code is a Unicode scalar value.
+
+ @since LibreOffice 6.0
+*/
+inline bool isUnicodeScalarValue(sal_uInt32 code)
+{
+ return isUnicodeCodePoint(code) && !isSurrogate(code);
+}
+
}
#endif