authorgravatar for kris.tate+github@gmail.comkristopher tate <kris.tate+github@gmail.com> 2018-09-01 19:40:05+09:00
committergravatar for kris.tate+github@gmail.comkristopher tate <kris.tate+github@gmail.com> 2018-09-01 19:40:05+09:00
log454b2362ee5e80dd1236535eaaec70d98e0d33ba
treec8f8f4c177d022945de5f8783fb72808c93cc279
parente036f65ac0df91b03dc6bcda8b043484321c6857

std/fmt/index.zig: #1358 allow bytes to be printed-out as hex;

Supports {x} for lowercase and {X} for uppercase;

1 files changed, 5 insertions(+), 0 deletions(-)

std/fmt/index.zig+5
...@@ -350,6 +350,11 @@ pub fn formatText(...@@ -350,6 +350,11 @@ pub fn formatText(
350 comptime var width = 0;350 comptime var width = 0;
351 if (fmt.len > 1) width = comptime (parseUnsigned(usize, fmt[1..], 10) catch unreachable);351 if (fmt.len > 1) width = comptime (parseUnsigned(usize, fmt[1..], 10) catch unreachable);
352 return formatBuf(bytes, width, context, Errors, output);352 return formatBuf(bytes, width, context, Errors, output);
353 } else if ((fmt[0] == 'x') or (fmt[0] == 'X') ) {
354 for (bytes) |c| {
355 try formatInt(c, 16, fmt[0] == 'X', 0, context, Errors, output);
356 }
357 return;
353 } else @compileError("Unknown format character: " ++ []u8{fmt[0]});358 } else @compileError("Unknown format character: " ++ []u8{fmt[0]});
354 }359 }
355 return output(context, bytes);360 return output(context, bytes);