Functions
fn calcUtf16LeLen(utf8: []const u8) CalcUtf16LeLenError!usize
Returns length in UTF-16 of UTF-8 slice as length of []u16. Length in []u8 is 2…
Returns length in UTF-16 of UTF-8 slice as length of []u16. Length in []u8 is 2*len16.
fn utf16CountCodepoints(utf16le: []const u16) !usize
Returns the length of a supplied UTF-16 string literal in terms of unicode code…
Returns the length of a supplied UTF-16 string literal in terms of unicode codepoints.
fn utf16leToUtf8(utf8: []u8, utf16le: []const u16) !usize
Asserts that the output buffer is big enough. Returns end byte index into utf8.
fn utf16leToUtf8Alloc(allocator: mem.Allocator, utf16le: []const u16) ![]u8
Caller must free returned memory.
fn utf16leToUtf8AllocZ(allocator: mem.Allocator, utf16le: []const u16) ![:0]u8
Caller must free returned memory.
fn utf8ByteSequenceLength(first_byte: u8) !u3
Given the first byte of a UTF-8 codepoint, returns a number 1-4 indicating the …
Given the first byte of a UTF-8 codepoint, returns a number 1-4 indicating the total length of the codepoint in bytes. If this byte does not match the form of a UTF-8 start byte, returns Utf8InvalidStartByte.
fn utf8CodepointSequenceLength(c: u21) !u3
Returns how many bytes the UTF-8 representation would require for the given cod…
Returns how many bytes the UTF-8 representation would require for the given codepoint.
fn utf8CountCodepoints(s: []const u8) !usize
Returns the length of a supplied UTF-8 string literal in terms of unicode codep…
Returns the length of a supplied UTF-8 string literal in terms of unicode codepoints.
fn utf8Decode(bytes: []const u8) Utf8DecodeError!u21
Decodes the UTF-8 codepoint encoded in the given slice of bytes. bytes.len must…
Decodes the UTF-8 codepoint encoded in the given slice of bytes. bytes.len must be equal to utf8ByteSequenceLength(bytes[0]) catch unreachable. If you already know the length at comptime, you can call one of utf8Decode2,utf8Decode3,utf8Decode4 directly instead of this function.
fn utf8Encode(c: u21, out: []u8) !u3
Encodes the given codepoint into a UTF-8 byte sequence. c: the codepoint. out:…
Encodes the given codepoint into a UTF-8 byte sequence. c: the codepoint. out: the out buffer to write to. Must have a len >= utf8CodepointSequenceLength(c). Errors: if c cannot be encoded in UTF-8. Returns: the number of bytes written to out.
fn utf8ToUtf16Le(utf16le: []u16, utf8: []const u8) !usize
Returns index of next character. If exact fit, returned index equals output slic…
Returns index of next character. If exact fit, returned index equals output slice length. Assumes there is enough space for the output.
fn utf8ToUtf16LeStringLiteral(comptime utf8: []const u8) *const [calcUtf16LeLen(utf8) catch unreachable:0]u16
Converts a UTF-8 string literal into a UTF-16LE string literal.
fn utf8ToUtf16LeWithNull(allocator: mem.Allocator, utf8: []const u8) ![:0]u16
No documentation provided.
fn utf8ValidCodepoint(value: u21) bool
Returns true if the given unicode codepoint can be encoded in UTF-8.
Values
replacement_character | u21 | Use this to replace an unknown, unrecognized, or unrepresentable character. |