diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-12-22 16:12:56 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-22 16:12:56 -0500 |
| commit | 28dbdba37eed0cfd875cfc337446da3048743dd9 (patch) | |
| tree | 71d3d4479809da72c5410e7dd49855805f25abe5 /lib/std/fmt.zig | |
| parent | ba1d213f480eb0cb7c8641a8d8cb1d6763e82438 (diff) | |
| parent | 9d31b65b34a222ff8b11d5bcaefcfc3c22ef4250 (diff) | |
| download | zig-28dbdba37eed0cfd875cfc337446da3048743dd9.tar.gz zig-28dbdba37eed0cfd875cfc337446da3048743dd9.zip | |
Merge pull request #3935 from Vexu/translate-c-2
Translate-c-2 the rest
Diffstat (limited to 'lib/std/fmt.zig')
| -rw-r--r-- | lib/std/fmt.zig | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig index 2eef92a201..f1249afa97 100644 --- a/lib/std/fmt.zig +++ b/lib/std/fmt.zig @@ -582,7 +582,9 @@ pub fn formatAsciiChar( comptime Errors: type, output: fn (@TypeOf(context), []const u8) Errors!void, ) Errors!void { - return output(context, @as(*const [1]u8, &c)[0..]); + if (std.ascii.isPrint(c)) + return output(context, @as(*const [1]u8, &c)[0..]); + return format(context, Errors, output, "\\x{x:0<2}", .{c}); } pub fn formatBuf( |
