diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/js_printer.zig | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/js_printer.zig b/src/js_printer.zig index 57ef580b6..709672f29 100644 --- a/src/js_printer.zig +++ b/src/js_printer.zig @@ -3180,10 +3180,26 @@ fn NewPrinter( hex_chars[cursor.c & 15], }); }, - else => { - p.print("\\u{"); - std.fmt.formatInt(cursor.c, 16, .lower, .{}, p) catch unreachable; - p.print("}"); + + else => |c| { + const k = c - 0x10000; + const lo = @as(usize, @intCast(first_high_surrogate + ((k >> 10) & 0x3FF))); + const hi = @as(usize, @intCast(first_low_surrogate + (k & 0x3FF))); + + p.print(&[_]u8{ + '\\', + 'u', + hex_chars[lo >> 12], + hex_chars[(lo >> 8) & 15], + hex_chars[(lo >> 4) & 15], + hex_chars[lo & 15], + '\\', + 'u', + hex_chars[hi >> 12], + hex_chars[(hi >> 8) & 15], + hex_chars[(hi >> 4) & 15], + hex_chars[hi & 15], + }); }, } }, |