aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/UniConversion.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/UniConversion.h')
-rw-r--r--src/UniConversion.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/UniConversion.h b/src/UniConversion.h
index 5990cca8c..ce5de4bc7 100644
--- a/src/UniConversion.h
+++ b/src/UniConversion.h
@@ -99,8 +99,12 @@ enum { SURROGATE_TRAIL_FIRST = 0xDC00 };
enum { SURROGATE_TRAIL_LAST = 0xDFFF };
enum { SUPPLEMENTAL_PLANE_FIRST = 0x10000 };
+constexpr bool IsSurrogate(wchar_t uch) noexcept {
+ return (uch >= SURROGATE_LEAD_FIRST) && (uch <= SURROGATE_TRAIL_LAST);
+}
+
constexpr unsigned int UTF16CharLength(wchar_t uch) noexcept {
- return ((uch >= SURROGATE_LEAD_FIRST) && (uch <= SURROGATE_LEAD_LAST)) ? 2 : 1;
+ return IsSurrogate(uch) ? 2 : 1;
}
constexpr unsigned int UTF16LengthFromUTF8ByteCount(unsigned int byteCount) noexcept {