| author | |
| committer | |
| log | 7e5e767ba0fdde91dd66690168eff96b75c28e33 |
| tree | a61f996ad83f99369b7273e50b8221f1b99ba2e4 |
| parent | 0267afa9c0aac51089150a9d2f6b2e53e9d2dbff |
Closes #40142 files changed, 9 insertions(+), 4 deletions(-)
lib/std/fmt.zig+1-3| ... | ... | @@ -585,9 +585,7 @@ pub fn formatAsciiChar( |
| 585 | 585 | comptime Errors: type, |
| 586 | 586 | output: fn (@TypeOf(context), []const u8) Errors!void, |
| 587 | 587 | ) Errors!void { |
| 588 | if (std.ascii.isPrint(c)) | |
| 589 | return output(context, @as(*const [1]u8, &c)[0..]); | |
| 590 | return format(context, Errors, output, "\\x{x:0<2}", .{c}); | |
| 588 | return output(context, @as(*const [1]u8, &c)[0..]); | |
| 591 | 589 | } |
| 592 | 590 | |
| 593 | 591 | pub fn formatBuf( |
src-self-hosted/translate_c.zig+8-1| ... | ... | @@ -1708,7 +1708,14 @@ fn escapeChar(c: u8, char_buf: *[4]u8) []const u8 { |
| 1708 | 1708 | '\n' => "\\n"[0..], |
| 1709 | 1709 | '\r' => "\\r"[0..], |
| 1710 | 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 |