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 › unicode › testRoundtripWtf16 Private Function testRoundtripWtf16 Doc Source Private Function std.unicode.testRoundtripWtf16
fn testRoundtripWtf16 (wtf16le : []const u16 ) !void Params File unicode.zig: 2104
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137 fn testRoundtripWtf16 (wtf16le : []const u16 ) !void {
// Buffer
{
var wtf8_buf : [32 ]u8 = undefined ;
const wtf8_len = wtf16LeToWtf8 (&wtf8_buf , wtf16le );
const wtf8 = wtf8_buf [0 ..wtf8_len ];
var roundtripped_buf : [32 ]u16 = undefined ;
const roundtripped_len = try wtf8ToWtf16Le (&roundtripped_buf , wtf8 );
const roundtripped = roundtripped_buf [0 ..roundtripped_len ];
try testing .expectEqualSlices (u16 , wtf16le , roundtripped );
}
// Alloc
{
const wtf8 = try wtf16LeToWtf8Alloc (testing .allocator , wtf16le );
defer testing .allocator .free (wtf8 );
const roundtripped = try wtf8ToWtf16LeAlloc (testing .allocator , wtf8 );
defer testing .allocator .free (roundtripped );
try testing .expectEqualSlices (u16 , wtf16le , roundtripped );
}
// AllocZ
{
const wtf8 = try wtf16LeToWtf8AllocZ (testing .allocator , wtf16le );
defer testing .allocator .free (wtf8 );
const roundtripped = try wtf8ToWtf16LeAllocZ (testing .allocator , wtf8 );
defer testing .allocator .free (roundtripped );
try testing .expectEqualSlices (u16 , wtf16le , roundtripped );
}
}