| ... | @@ -352,7 +352,7 @@ pub fn formatText( | ... | @@ -352,7 +352,7 @@ pub fn formatText( |
| 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') ) { | 353 | } else if ((fmt[0] == 'x') or (fmt[0] == 'X') ) { |
| 354 | for (bytes) |c| { | 354 | for (bytes) |c| { |
| 355 | try formatInt(c, 16, fmt[0] == 'X', 0, context, Errors, output); | 355 | try formatInt(c, 16, fmt[0] == 'X', 2, context, Errors, output); |
| 356 | } | 356 | } |
| 357 | return; | 357 | return; |
| 358 | } else @compileError("Unknown format character: " ++ []u8{fmt[0]}); | 358 | } else @compileError("Unknown format character: " ++ []u8{fmt[0]}); |
| ... | @@ -1281,6 +1281,8 @@ test "fmt.format" { | ... | @@ -1281,6 +1281,8 @@ test "fmt.format" { |
| 1281 | const some_bytes = "\xCA\xFE\xBA\xBE"; | 1281 | const some_bytes = "\xCA\xFE\xBA\xBE"; |
| 1282 | try testFmt("lowercase: cafebabe\n", "lowercase: {x}\n", some_bytes); | 1282 | try testFmt("lowercase: cafebabe\n", "lowercase: {x}\n", some_bytes); |
| 1283 | try testFmt("uppercase: CAFEBABE\n", "uppercase: {X}\n", some_bytes); | 1283 | try testFmt("uppercase: CAFEBABE\n", "uppercase: {X}\n", some_bytes); |
| | 1284 | const bytes_with_zeros = "\x00\x0E\xBA\xBE"; |
| | 1285 | try testFmt("lowercase: 000ebabe\n", "lowercase: {x}\n", bytes_with_zeros); |
| 1284 | } | 1286 | } |
| 1285 | } | 1287 | } |
| 1286 | | 1288 | |