escape consecutive unpaired surrogates (#2576)

fixes #2569
This commit is contained in:
Alex Lam S.L
2017-12-11 01:15:44 +08:00
committed by GitHub
parent bf000beae7
commit 93f3b2b114
3 changed files with 29 additions and 5 deletions

View File

@@ -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;
};