std/fmt/index.zig: #1358 allow bytes to be printed-out as hex;
Supports {x} for lowercase and {X} for uppercase;
This commit is contained in:
parent
e036f65ac0
commit
454b2362ee
@ -350,6 +350,11 @@ pub fn formatText(
|
||||
comptime var width = 0;
|
||||
if (fmt.len > 1) width = comptime (parseUnsigned(usize, fmt[1..], 10) catch unreachable);
|
||||
return formatBuf(bytes, width, context, Errors, output);
|
||||
} else if ((fmt[0] == 'x') or (fmt[0] == 'X') ) {
|
||||
for (bytes) |c| {
|
||||
try formatInt(c, 16, fmt[0] == 'X', 0, context, Errors, output);
|
||||
}
|
||||
return;
|
||||
} else @compileError("Unknown format character: " ++ []u8{fmt[0]});
|
||||
}
|
||||
return output(context, bytes);
|
||||
|
Loading…
x
Reference in New Issue
Block a user