From 0b3ca115206c0332284c80f7f7d42358d96379c1 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 15 Feb 2026 16:04:44 -0800 Subject: [PATCH] std.Io.Writer: placeholder code for new {q} format character intendend to print something with double quotes, escaped the same as a zig string literal. --- lib/std/Io/Writer.zig | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/std/Io/Writer.zig b/lib/std/Io/Writer.zig index 813142a7a35e48c1de0eaba49bea2a5f47ec1139..c489a5c93d6ef3b4adcf94a2eca16daff8a56eee 100644 --- a/lib/std/Io/Writer.zig +++ b/lib/std/Io/Writer.zig @@ -1172,6 +1172,25 @@ pub fn printValue( }, else => invalidFmtError(fmt, value), }, + // TODO make this print double quotes and quote-escape the string + // according to zig string syntax rules + 'q' => switch (@typeInfo(T)) { + .pointer => |info| switch (info.size) { + .one, .slice => { + const slice: []const u8 = value; + return w.alignBufferOptions(slice, options); + }, + .many, .c => { + const slice: [:0]const u8 = std.mem.span(value); + return w.alignBufferOptions(slice, options); + }, + }, + .array => { + const slice: []const u8 = &value; + return w.alignBufferOptions(slice, options); + }, + else => invalidFmtError(fmt, value), + }, 'B' => switch (@typeInfo(T)) { .int, .comptime_int => return w.printByteSize(value, .decimal, options), .@"struct" => return value.formatByteSize(w, .decimal), -- 2.54.0