# "{q}" prints strings nicely but what about a single character?

**URL:** <https://ziggit.dev/t/q-prints-strings-nicely-but-what-about-a-single-character/18033>\
**Category:** Brainstorming\
**Tags:** standard-library\
**Created:** [October 20, 2026, 5:30am UTC](https://ziggit.dev/t/q-prints-strings-nicely-but-what-about-a-single-character/18033 "2026-10-20T05:30:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![truly-not-taken](https://ziggit.dev/user_avatar/ziggit.dev/truly-not-taken/32/6205_2.png) [@truly-not-taken](https://ziggit.dev/u/truly-not-taken)\
**Post date:** [October 20, 2026, 5:30am UTC](https://ziggit.dev/t/q-prints-strings-nicely-but-what-about-a-single-character/18033/1 "2026-10-20T05:30:33Z")

</div>

```zig
test "print u8 with {q}" {
    const expected: u8 = 'a';
    const actual: u8 = '\t';

    // this does not compile
    // errdefer std.debug.print("expected {q}, found {q}\n", .{
    // expected,
    // actual,
    // });

    // this does not escape control characters
    errdefer std.debug.print("expected '{c}', found '{c}'\n", .{
        expected,
        actual,
    });

    // this prints double quotes instead of single quotes
    errdefer std.debug.print("expected {q}, found {q}\n", .{
        (&expected)[0..1],
        (&actual)[0..1],
    });

    // this prints numbers instead of characters
    try std.testing.expectEqual(expected, actual);
}

```

It would be nice to print ASCII characters with `"{qc}"` and Unicode with `"{qu}"`. Is this already planned? Did I miss the announcement?

Edit: I fail to understand `"{u}"` [documentation](https://codeberg.org/ziglang/zig/src/commit/64caa0e324d522915769dd5cc8a11374f919f01f/lib/std/Io/Writer.zig#L675). How can a 21-bit integer be an UTF-8 sequence?

---

<div class="post-metadata">

**Author:** ![vulpesx](https://ziggit.dev/user_avatar/ziggit.dev/vulpesx/32/3989_2.png) [@vulpesx](https://ziggit.dev/u/vulpesx)\
**Post date:** [October 20, 2026, 7:23am UTC](https://ziggit.dev/t/q-prints-strings-nicely-but-what-about-a-single-character/18033/2 "2026-10-20T07:23:50Z")

</div>

> [@truly-not-taken](#):
>
> Edit: I fail to understand `"{u}"` [documentation](https://codeberg.org/ziglang/zig/src/commit/64caa0e324d522915769dd5cc8a11374f919f01f/lib/std/Io/Writer.zig#L675). How can a 21-bit integer be an UTF-8 sequence?

a utf-8 sequence is 1-4 bytes, that is 8-32 bits, some of which encode the length and indicate bytes that are part of a larger sequence, the larger 4 byte sequence has 24 bits of usable values.

You also have it backwards, utf-8 is an encoding for a sequence of 21 bit unicode code points.

* * *

to actually answer your question:you can implement it yourself, ofc re-using code from [`std.Io.Writer.printStringEscaped`](https://ziglang.org/documentation/0.17.0/std/#std.Io.Writer.printStringEscaped)

And for other reference, there is a `{qf}` specifier to call a format function with a `std.zig.StringEscapeWriter` (just a writer implementation, dont need to change fn signature), however `print` still writes the `""` around it. So it doesnt help this case.

---

<div class="post-metadata">

**Author:** ![squeek502](https://ziggit.dev/user_avatar/ziggit.dev/squeek502/32/409_2.png) [@squeek502](https://ziggit.dev/u/squeek502)\
**Post date:** [October 20, 2026, 7:41am UTC](https://ziggit.dev/t/q-prints-strings-nicely-but-what-about-a-single-character/18033/3 "2026-10-20T07:41:40Z")

</div>

```zig
std.debug.print("expected '{f}', found '{f}'\n", .{
    std.zig.fmtChar(expected),
    std.zig.fmtChar(actual),
});

```

```plaintext
expected 'a', found '\t'

```
