aboutsummaryrefslogtreecommitdiff
path: root/lib/parse.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-12-11 01:15:44 +0800
committerGitHub <noreply@github.com>2017-12-11 01:15:44 +0800
commit93f3b2b114877af17db219e501ae4551df61738d (patch)
tree30ab311ab09b9dc4f98b098c8d7fa3a84dc91393 /lib/parse.js
parentbf000beae710a2b4129bddb009bb706ff036fbb6 (diff)
downloadtracifyjs-93f3b2b114877af17db219e501ae4551df61738d.tar.gz
tracifyjs-93f3b2b114877af17db219e501ae4551df61738d.zip
escape consecutive unpaired surrogates (#2576)
fixes #2569
Diffstat (limited to 'lib/parse.js')
-rw-r--r--lib/parse.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/parse.js b/lib/parse.js
index 099fc49a..f0098c75 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -132,6 +132,18 @@ function is_letter(code) {
|| (code >= 0xaa && UNICODE.letter.test(String.fromCharCode(code)));
};
+function is_surrogate_pair_head(code) {
+ if (typeof code == "string")
+ code = code.charCodeAt(0);
+ return code >= 0xd800 && code <= 0xdbff;
+}
+
+function is_surrogate_pair_tail(code) {
+ if (typeof code == "string")
+ code = code.charCodeAt(0);
+ return code >= 0xdc00 && code <= 0xdfff;
+}
+
function is_digit(code) {
return code >= 48 && code <= 57;
};