Function fmtEscapes [src]

Return a Formatter for Zig Escapes of a double quoted string. The format specifier must be one of: {} treats contents as a double-quoted string. {'} treats contents as a single-quoted string.

Prototype

pub fn fmtEscapes(bytes: []const u8) std.fmt.Formatter(stringEscape)

Parameters

bytes: []const u8

Example

test fmtEscapes { const expectFmt = std.testing.expectFmt; try expectFmt("\\x0f", "{}", .{fmtEscapes("\x0f")}); try expectFmt( \\" \\ hi \x07 \x11 " derp \'" , "\"{'}\"", .{fmtEscapes(" \\ hi \x07 \x11 \" derp '")}); try expectFmt( \\" \\ hi \x07 \x11 \" derp '" , "\"{}\"", .{fmtEscapes(" \\ hi \x07 \x11 \" derp '")}); }

Source

pub fn fmtEscapes(bytes: []const u8) std.fmt.Formatter(stringEscape) { return .{ .data = bytes }; }