Zig 0.17.0-dev (Split by item) This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig standard library.
std › zig › charEscape Public Function charEscape Doc Source Public Function std.zig.charEscape
pub fn charEscape (codepoint : u21 , w : *Writer ) Writer .Error !void Params File zig.zig: 634
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653 pub fn charEscape (codepoint : u21 , w : *Writer ) Writer .Error !void {
switch (codepoint ) {
'\n' => try w .writeAll ("\\n" ),
'\r' => try w .writeAll ("\\r" ),
'\t' => try w .writeAll ("\\t" ),
'\\' => try w .writeAll ("\\\\" ),
'\'' => try w .writeAll ("\\'" ),
'"' , ' ' , '!' , '#' ...'&' , '(' ...'[' , ']' ...'~' => try w .writeByte (@intCast (codepoint )),
else => {
if (std .math .cast (u8 , codepoint )) |byte | {
try w .writeAll ("\\x" );
try w .printInt (byte , 16 , .lower , .{ .width = 2 , .fill = '0' });
} else {
try w .writeAll ("\\u{" );
try w .printInt (codepoint , 16 , .lower , .{});
try w .writeByte ('}' );
}
},
}
}
Print as escaped contents of a single-quoted string.