| ... | @@ -1708,7 +1708,14 @@ fn escapeChar(c: u8, char_buf: *[4]u8) []const u8 { | ... | @@ -1708,7 +1708,14 @@ fn escapeChar(c: u8, char_buf: *[4]u8) []const u8 { |
| 1708 | '\n' => "\\n"[0..], | 1708 | '\n' => "\\n"[0..], |
| 1709 | '\r' => "\\r"[0..], | 1709 | '\r' => "\\r"[0..], |
| 1710 | '\t' => "\\t"[0..], | 1710 | '\t' => "\\t"[0..], |
| 1711 | else => std.fmt.bufPrint(char_buf[0..], "{c}", .{c}) catch unreachable, | 1711 | else => { |
| | 1712 | // Handle the remaining escapes Zig doesn't support by turning them |
| | 1713 | // into their respective hex representation |
| | 1714 | if (std.ascii.isCntrl(c)) |
| | 1715 | return std.fmt.bufPrint(char_buf[0..], "\\x{x:0<2}", .{c}) catch unreachable |
| | 1716 | else |
| | 1717 | return std.fmt.bufPrint(char_buf[0..], "{c}", .{c}) catch unreachable; |
| | 1718 | }, |
| 1712 | }; | 1719 | }; |
| 1713 | } | 1720 | } |
| 1714 | | 1721 | |