summaryrefslogtreecommitdiff
path: root/js/src/vm/Unicode.h
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/vm/Unicode.h')
-rw-r--r--js/src/vm/Unicode.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/js/src/vm/Unicode.h b/js/src/vm/Unicode.h
index e470f43418..b1e3e17c61 100644
--- a/js/src/vm/Unicode.h
+++ b/js/src/vm/Unicode.h
@@ -466,6 +466,19 @@ IsTrailSurrogate(uint32_t codePoint)
return codePoint >= TrailSurrogateMin && codePoint <= TrailSurrogateMax;
}
+/**
+ * Returns true if the given value is a UTF-16 surrogate.
+ *
+ * This function is intended for use in contexts where 32-bit values may need
+ * to be tested to see if they reside in the surrogate range, so it doesn't
+ * just take char16_t.
+ */
+inline bool
+IsSurrogate(uint32_t codePoint)
+{
+ return LeadSurrogateMin <= codePoint && codePoint <= TrailSurrogateMax;
+}
+
inline char16_t
LeadSurrogate(uint32_t codePoint)
{