JS: Extract surrogate pairs as one constant node

This commit is contained in:
Asger F
2019-10-24 12:23:30 +01:00
parent 6e1c995f2f
commit 68d23bcf8c
2 changed files with 9 additions and 2 deletions

View File

@@ -489,6 +489,11 @@ public class RegExpParser {
if (this.match("b")) return this.finishTerm(new ControlEscape(loc, "\b", 8, "\\b"));
return this.finishTerm(this.parseAtomEscape(loc, true));
}
return this.finishTerm(new Constant(loc, String.valueOf(c)));
String value = String.valueOf(c);
// Extract a surrogate pair as a single constant.
if (Character.isHighSurrogate(c) && Character.isLowSurrogate(peekChar(true))) {
value += this.nextChar();
}
return this.finishTerm(new Constant(loc, value));
}
}