Skip to content

Commit 6af9b46

Browse files
committed
check ascii_only first
1 parent 5821fd7 commit 6af9b46

File tree

1 file changed

+3
-1
lines changed
  • crates/swc_ecma_codegen/src

1 file changed

+3
-1
lines changed

crates/swc_ecma_codegen/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4285,7 +4285,9 @@ fn get_quoted_utf16(v: &str, ascii_only: bool, target: EsVersion) -> String {
42854285
// to make sure we output unicode that is safe for the target
42864286
// Es5 does not support code point escapes and so surrograte formula must be
42874287
// used
4288-
if target <= EsVersion::Es5 {
4288+
if !ascii_only {
4289+
let _ = write!(buf, "{}", c);
4290+
} else if target <= EsVersion::Es5 {
42894291
// https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
42904292
let h = ((c as u32 - 0x10000) / 0x400) + 0xd800;
42914293
let l = (c as u32 - 0x10000) % 0x400 + 0xdc00;

0 commit comments

Comments
 (0)