Function wtf8ToWtf16LeAllocZ [src]

Prototype

pub fn wtf8ToWtf16LeAllocZ(allocator: mem.Allocator, wtf8: []const u8) error{ InvalidWtf8, OutOfMemory }![:0]u16

Parameters

allocator: mem.Allocatorwtf8: []const u8

Possible Errors

InvalidWtf8
OutOfMemory

Source

pub fn wtf8ToWtf16LeAllocZ(allocator: mem.Allocator, wtf8: []const u8) error{ InvalidWtf8, OutOfMemory }![:0]u16 { // optimistically guess that it will not require surrogate pairs var result = try std.ArrayList(u16).initCapacity(allocator, wtf8.len + 1); errdefer result.deinit(); try utf8ToUtf16LeArrayListImpl(&result, wtf8, .can_encode_surrogate_half); return result.toOwnedSliceSentinel(0); }