From 8ecaa40c6e7c9936476b22e994947982a40e0b50 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Mon, 19 Oct 2020 02:34:17 +0100 Subject: extend support for Unicode (#4228) --- lib/output.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/output.js') 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) { -- cgit v1.2.3