Closed
Description
Zig Version
0.11.0
Steps to Reproduce and Observed Behavior
When using some UTF-8 characters to pad/fill the output, print()
fails. In the example below, while padding with +
signs works as expected, padding with ─
does not. The character ─
is a box drawing character, useful e.g. when drawing tables with text in the terminal.
const std = @import("std");
pub fn main() !void {
// std.debug.print("{?s:+^20}\n", .{"test"}); // WORKS
// Output: ++++++++test++++++++
std.debug.print("{?s:─^20}\n", .{"test"}); // DOES NOT WORK
}
❯ zig run main.zig
/nix/store/2rnf5zzshg65zw7g82bph1i1dph2z2r6-zig-0.11.0/lib/zig/std/fmt.zig:268:17: error: expected . or }, found '�
@compileError("expected . or }, found '" ++ [1]u8{ch} ++ "'");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/nix/store/2rnf5zzshg65zw7g82bph1i1dph2z2r6-zig-0.11.0/lib/zig/std/fmt.zig:151:55: note: called from here
const placeholder = comptime Placeholder.parse(fmt[fmt_begin..fmt_end].*);
~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
Expected Behavior
For the padding to work with any printable character.