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 › stringEscapeCounting Public Function stringEscapeCounting Doc Source Public Function std.zig.stringEscapeCounting
pub fn stringEscapeCounting (bytes : []const u8 , w : *Writer ) Writer .Error !usize Params File zig.zig: 551
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585 pub fn stringEscapeCounting (bytes : []const u8 , w : *Writer ) Writer .Error !usize {
var n : usize = 0 ;
for (bytes ) |byte | switch (byte ) {
'\t' => {
try w .writeAll ("\\t" );
n += 2 ;
},
'\n' => {
try w .writeAll ("\\n" );
n += 2 ;
},
'\r' => {
try w .writeAll ("\\r" );
n += 2 ;
},
'\\' => {
try w .writeAll ("\\\\" );
n += 2 ;
},
'"' => {
try w .writeAll ("\\\"" );
n += 2 ;
},
0 ...8 , 11 , 12 , 14 ...0x1f , 0x7f => {
try w .writeAll ("\\x" );
try w .printInt (byte , 16 , .lower , .{ .width = 2 , .fill = '0' });
n += 4 ;
},
else => {
try w .writeByte (byte );
n += 1 ;
},
};
return n ;
}