https://learn.microsoft.com/en-us/windows/win32/intl/code-page-identifiers
pub const SupportedCodePage = enum(u16)
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..]);
},
}
}
}