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 library itself.

SupportedCodePage

https://learn.microsoft.com/en-us/windows/win32/intl/code-page-identifiers

code_pages.SupportedCodePage
pub const SupportedCodePage = enum(u16)

File

lib/compiler/resinator/code_pages.zig:5

Code

pub const SupportedCodePage = enum(u16) {
    windows1252 = 1252, // windows-1252    ANSI Latin 1; Western European (Windows)
    utf8 = 65001, // utf-8    Unicode (UTF-8)

    pub fn codepointAt(code_page: SupportedCodePage, index: usize, bytes: []const u8) ?Codepoint {
        if (index >= bytes.len) return null;
        switch (code_page) {
            .windows1252 => {
                // All byte values have a representation, so just convert the byte
                return Codepoint{
                    .value = windows1252.toCodepoint(bytes[index]),
                    .byte_len = 1,
                };
            },
            .utf8 => {
                return Utf8.WellFormedDecoder.decode(bytes[index..]);
            },
        }
    }
}