aboutsummaryrefslogtreecommitdiff
path: root/lib/output.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-10-19 02:34:17 +0100
committerGitHub <noreply@github.com>2020-10-19 09:34:17 +0800
commit8ecaa40c6e7c9936476b22e994947982a40e0b50 (patch)
tree6d2d9510a23541541aa98996f9ecc6026cdf1efc /lib/output.js
parent96bf7fceabf1670ca07c08a04a3130e742775c8f (diff)
downloadtracifyjs-8ecaa40c6e7c9936476b22e994947982a40e0b50.tar.gz
tracifyjs-8ecaa40c6e7c9936476b22e994947982a40e0b50.zip
extend support for Unicode (#4228)
Diffstat (limited to 'lib/output.js')
-rw-r--r--lib/output.js3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/output.js b/lib/output.js
index 8068648e..ef1d41f6 100644
--- a/lib/output.js
+++ b/lib/output.js
@@ -107,6 +107,9 @@ function OutputStream(options) {
var OUTPUT = "";
var to_utf8 = options.ascii_only ? function(str, identifier) {
+ if (identifier) str = str.replace(/[\ud800-\udbff][\udc00-\udfff]/g, function(ch) {
+ return "\\u{" + (ch.charCodeAt(0) - 0xd7c0 << 10 | ch.charCodeAt(1) - 0xdc00).toString(16) + "}";
+ });
return str.replace(/[\u0000-\u001f\u007f-\uffff]/g, function(ch) {
var code = ch.charCodeAt(0).toString(16);
if (code.length <= 2 && !identifier) {