Lyricdev
GitHub

struct Utf16

pub struct Utf16

Text as UTF-16 code units and back. A unit that is half of a surrogate pair without its other half is not UTF-16.

Methods

pub static fn encode(s: StringView): uint16[]

Returns s as UTF-16 code units, characters above U+FFFF as surrogate pairs.

pub static fn decode(units: Slice<uint16>): string throws EncodingError

Returns the text that the UTF-16 code units units encode.

Errors

Throws EncodingError at a high surrogate not followed by a low one, and at a low surrogate not preceded by a high one.