std.utf16
utf-8 <-> utf-16 (native order, no bom); malformed input fails, never repaired
Utf16Error
Section titled “Utf16Error”pub Utf16Error :: errors { invalid_utf8, invalid_utf16, buffer_too_small, out_of_memory,}invalid_utf8: the UTF-8 input is not well formedinvalid_utf16: the UTF-16 input has an unpaired surrogatebuffer_too_small: the destination cannot hold the whole resultout_of_memory: the arena could not supply the result’s storage
utf16_len
Section titled “utf16_len”pub utf16_len :: fn(src: []const u8) -> usize ! Utf16Errorexact utf-16 length in units; .invalid_utf8
utf8_len
Section titled “utf8_len”pub utf8_len :: fn(src: []const u16) -> usize ! Utf16Errorexact utf-8 length in bytes; .invalid_utf16
utf8_to_utf16
Section titled “utf8_to_utf16”pub utf8_to_utf16 :: fn(src: []const u8, dst: []u16) -> usize ! Utf16Errorreturns units written; .invalid_utf8, .buffer_too_small; dst untouched on error
utf16_to_utf8
Section titled “utf16_to_utf8”pub utf16_to_utf8 :: fn(src: []const u16, dst: []u8) -> usize ! Utf16Errorreturns bytes written; .invalid_utf16, .buffer_too_small; dst untouched on error
alloc_utf16
Section titled “alloc_utf16”pub alloc_utf16 :: fn(a: *Arena, src: []const u8) -> []u16 ! Utf16Errorin a; .invalid_utf8, .out_of_memory
alloc_utf16z
Section titled “alloc_utf16z”pub alloc_utf16z :: fn(a: *Arena, src: []const u8) -> []u16 ! Utf16Erroralloc_utf16 plus a 0 unit after the end (LPCWSTR); len excludes it
alloc_utf8
Section titled “alloc_utf8”pub alloc_utf8 :: fn(a: *Arena, src: []const u16) -> []u8 ! Utf16Errorin a; .invalid_utf16, .out_of_memory