pub fn calcUtf16LeLen(utf8: []const u8) CalcUtf16LeLenError!usize
Returns length in UTF-16LE of UTF-8 slice as length of []u16.
- Kind
- function
- Module
std.unicode
pub fn calcUtf16LeLenImpl(utf8: []const u8, comptime surrogates: Surrogates) !usize
- Kind
- function
- Module
std.unicode
pub fn calcWtf8Len(wtf16le: []const u16) usize
Returns the length, in bytes, that would be necessary to encode the given WTF-16 LE slice as WTF-8.
- Kind
- function
- Module
std.unicode
pub fn calcWtf16LeLen(wtf8: []const u8) CalcWtf16LeLenError!usize
Returns length in WTF-16LE of WTF-8 slice as length of []u16.
- Kind
- function
- Module
std.unicode
pub fn fmtUtf8(utf8: []const u8) std.fmt.Alt([]const u8, formatUtf8)
Return a Formatter for a (potentially ill-formed) UTF-8 string.
- Kind
- function
- Module
std.unicode
pub fn fmtUtf16Le(utf16le: []const u16) std.fmt.Alt([]const u16, formatUtf16Le)
Return a Formatter for a (potentially ill-formed) UTF-16 LE string, which will be converted to UTF-8 during formatting.
- Kind
- function
- Module
std.unicode
pub fn isSurrogateCodepoint(c: u21) bool
Returns true if the codepoint is a surrogate (U+DC00 to U+DFFF).
- Kind
- function
- Module
std.unicode
Use this to replace an unknown, unrecognized, or unrepresentable character.
- Kind
- constant
- Module
std.unicode
- Kind
- constant
- Module
std.unicode
pub fn utf8ByteSequenceLength(first_byte: u8) !u3
Given the first byte of a UTF-8 codepoint, returns a number 1-4 indicating the total length of the codepoint in bytes.
- Kind
- function
- Module
std.unicode
pub fn utf8CodepointSequenceLength(c: u21) !u3
Returns how many bytes the UTF-8 representation would require for the given codepoint.
- Kind
- function
- Module
std.unicode
pub fn utf8CountCodepoints(s: []const u8) !usize
Returns the length of a supplied UTF-8 string literal in terms of unicode codepoints.
- Kind
- function
- Module
std.unicode
pub fn utf8Decode2(bytes: [2]u8) Utf8Decode2Error!u21
- Kind
- function
- Module
std.unicode
pub fn utf8Decode3(bytes: [3]u8) Utf8Decode3Error!u21
- Kind
- function
- Module
std.unicode
pub fn utf8Decode3AllowSurrogateHalf(bytes: [3]u8) Utf8Decode3AllowSurrogateHalfError!u21
- Kind
- function
- Module
std.unicode
pub fn utf8Decode4(bytes: [4]u8) Utf8Decode4Error!u21
- Kind
- function
- Module
std.unicode
pub fn utf8Encode(c: u21, out: []u8) error
Encodes the given codepoint into a UTF-8 byte sequence. c: the codepoint. out: the out buffer to write to.
- Kind
- function
- Module
std.unicode
pub fn utf8EncodeComptime(comptime c: u21) [ utf8CodepointSequenceLength(c) catch |err| @compileError(@errorName(err)) ]u8
- Kind
- function
- Module
std.unicode
- Kind
- struct
- Module
std.unicode
pub fn nextCodepoint(it: *Utf8Iterator) ?u21
- Kind
- function
- Module
std.unicode
pub fn nextCodepointSlice(it: *Utf8Iterator) ?[]const u8
- Kind
- function
- Module
std.unicode
pub fn peek(it: *Utf8Iterator, n: usize) []const u8
Look ahead at the next n codepoints without advancing the iterator.
- Kind
- function
- Module
std.unicode
pub fn peekCodepoint(it: *Utf8Iterator) ?u21
Look ahead at the next codepoint without advancing the iterator.
- Kind
- function
- Module
std.unicode
pub fn utf8ToUtf16Le(utf16le: []u16, utf8: []const u8) error
Returns index of next character.
- Kind
- function
- Module
std.unicode
pub fn utf8ToUtf16LeAlloc(allocator: Allocator, utf8: []const u8) error
- Kind
- function
- Module
std.unicode
pub fn utf8ToUtf16LeAllocZ(allocator: Allocator, utf8: []const u8) error
- Kind
- function
- Module
std.unicode
pub fn utf8ToUtf16LeArrayList(result: *std.array_list.Managed(u16), utf8: []const u8) error
- Kind
- function
- Module
std.unicode
pub fn utf8ToUtf16LeImpl(utf16le: []u16, utf8: []const u8, comptime surrogates: Surrogates) !usize
- Kind
- function
- Module
std.unicode
pub fn utf8ToUtf16LeStringLiteral(comptime utf8: []const u8) *const [calcUtf16LeLen(utf8) catch |err| @compileError(err):0]u16
Converts a UTF-8 string literal into a UTF-16LE string literal.
- Kind
- function
- Module
std.unicode
pub fn utf8ValidateSlice(input: []const u8) bool
Returns true if the input consists entirely of UTF-8 codepoints.
- Kind
- function
- Module
std.unicode
pub fn utf8ValidCodepoint(value: u21) bool
Returns true if the given unicode codepoint can be encoded in UTF-8.
- Kind
- function
- Module
std.unicode
- Kind
- struct
- Module
std.unicode
pub fn init(s: []const u8) !Utf8View
- Kind
- function
- Module
std.unicode
pub fn initComptime(comptime s: []const u8) Utf8View
- Kind
- function
- Module
std.unicode
pub fn initUnchecked(s: []const u8) Utf8View
- Kind
- function
- Module
std.unicode
pub fn iterator(s: Utf8View) Utf8Iterator
- Kind
- function
- Module
std.unicode
pub fn utf16CodepointSequenceLength(c: u21) !u2
Returns how many code units the UTF-16 representation would require for the given codepoint.
- Kind
- function
- Module
std.unicode
pub fn utf16CodeUnitSequenceLength(first_code_unit: u16) !u2
Given the first code unit of a UTF-16 codepoint, returns a number 1-2 indicating the total length of the codepoint in UTF-16 code units.
- Kind
- function
- Module
std.unicode
pub fn utf16CountCodepoints(utf16le: []const u16) !usize
Returns the length of a supplied UTF-16 string literal in terms of unicode codepoints.
- Kind
- function
- Module
std.unicode
pub fn utf16DecodeSurrogatePair(surrogate_pair: []const u16) !u21
Decodes the codepoint encoded in the given pair of UTF-16 code units.
- Kind
- function
- Module
std.unicode
pub fn utf16IsHighSurrogate(c: u16) bool
- Kind
- function
- Module
std.unicode
pub fn utf16IsLowSurrogate(c: u16) bool
- Kind
- function
- Module
std.unicode
- Kind
- struct
- Module
std.unicode
pub fn init(s: []const u16) Utf16LeIterator
- Kind
- function
- Module
std.unicode
pub fn nextCodepoint(it: *Utf16LeIterator) NextCodepointError!?u21
- Kind
- function
- Module
std.unicode
- Kind
- error set
- Module
std.unicode
pub fn utf16LeToUtf8(utf8: []u8, utf16le: []const u16) Utf16LeToUtf8Error!usize
- Kind
- function
- Module
std.unicode
pub fn utf16LeToUtf8Alloc(allocator: Allocator, utf16le: []const u16) Utf16LeToUtf8AllocError![]u8
Caller owns returned memory.
- Kind
- function
- Module
std.unicode
- Kind
- type
- Module
std.unicode
pub fn utf16LeToUtf8AllocZ(allocator: Allocator, utf16le: []const u16) Utf16LeToUtf8AllocError![:0]u8
Caller owns returned memory.
- Kind
- function
- Module
std.unicode
pub fn utf16LeToUtf8ArrayList(result: *std.array_list.Managed(u8), utf16le: []const u16) Utf16LeToUtf8AllocError!void
- Kind
- function
- Module
std.unicode
- Kind
- type
- Module
std.unicode
pub fn wtf8Encode(c: u21, out: []u8) error
Encodes the given codepoint into a WTF-8 byte sequence. c: the codepoint. out: the out buffer to write to.
- Kind
- function
- Module
std.unicode
- Kind
- struct
- Module
std.unicode
pub fn nextCodepoint(it: *Wtf8Iterator) ?u21
- Kind
- function
- Module
std.unicode
pub fn nextCodepointSlice(it: *Wtf8Iterator) ?[]const u8
- Kind
- function
- Module
std.unicode
pub fn peek(it: *Wtf8Iterator, n: usize) []const u8
Look ahead at the next n codepoints without advancing the iterator.
- Kind
- function
- Module
std.unicode
pub fn peekCodepoint(it: *Wtf8Iterator) ?u21
Look ahead at the next codepoint without advancing the iterator.
- Kind
- function
- Module
std.unicode
pub fn wtf8ToUtf8Lossy(utf8: []u8, wtf8: []const u8) error
Surrogate codepoints (U+D800 to U+DFFF) are replaced by the Unicode replacement character (U+FFFD).
- Kind
- function
- Module
std.unicode
pub fn wtf8ToUtf8LossyAlloc(allocator: Allocator, wtf8: []const u8) error
- Kind
- function
- Module
std.unicode
pub fn wtf8ToUtf8LossyAllocZ(allocator: Allocator, wtf8: []const u8) error
- Kind
- function
- Module
std.unicode
pub fn wtf8ToWtf16Le(wtf16le: []u16, wtf8: []const u8) error
Returns index of next character.
- Kind
- function
- Module
std.unicode
pub fn wtf8ToWtf16LeAlloc(allocator: Allocator, wtf8: []const u8) error
- Kind
- function
- Module
std.unicode
pub fn wtf8ToWtf16LeAllocZ(allocator: Allocator, wtf8: []const u8) error
- Kind
- function
- Module
std.unicode
pub fn wtf8ToWtf16LeArrayList(result: *std.array_list.Managed(u16), wtf8: []const u8) error
- Kind
- function
- Module
std.unicode
pub fn wtf8ToWtf16LeStringLiteral(comptime wtf8: []const u8) *const [calcWtf16LeLen(wtf8) catch |err| @compileError(err):0]u16
Converts a WTF-8 string literal into a WTF-16LE string literal.
- Kind
- function
- Module
std.unicode
pub fn wtf8ValidateSlice(input: []const u8) bool
Returns true if the input consists entirely of WTF-8 codepoints (all the same restrictions as UTF-8, but allows surrogate codepoints U+D800 to U+DFFF).
- Kind
- function
- Module
std.unicode
- Kind
- struct
- Module
std.unicode
pub fn init(s: []const u8) error
- Kind
- function
- Module
std.unicode
pub fn initComptime(comptime s: []const u8) Wtf8View
- Kind
- function
- Module
std.unicode
pub fn initUnchecked(s: []const u8) Wtf8View
- Kind
- function
- Module
std.unicode
pub fn iterator(s: Wtf8View) Wtf8Iterator
- Kind
- function
- Module
std.unicode
- Kind
- struct
- Module
std.unicode
pub fn init(s: []const u16) Wtf16LeIterator
- Kind
- function
- Module
std.unicode
pub fn nextCodepoint(it: *Wtf16LeIterator) ?u21
If the next codepoint is encoded by a surrogate pair, returns the codepoint that the surrogate pair represents.
- Kind
- function
- Module
std.unicode
pub fn wtf16LeToWtf8(wtf8: []u8, wtf16le: []const u16) usize
- Kind
- function
- Module
std.unicode
pub fn wtf16LeToWtf8Alloc(allocator: Allocator, wtf16le: []const u16) Allocator.Error![]u8
Caller must free returned memory.
- Kind
- function
- Module
std.unicode
pub fn wtf16LeToWtf8AllocZ(allocator: Allocator, wtf16le: []const u16) Allocator.Error![:0]u8
Caller must free returned memory.
- Kind
- function
- Module
std.unicode
pub fn wtf16LeToWtf8ArrayList(result: *std.array_list.Managed(u8), utf16le: []const u16) Allocator.Error!void
- Kind
- function
- Module
std.unicode