Static methods

staticcodepoint(buffer:View<UInt8>):Char32

Decodes a UTF-16 encoded codepoint from the buffer. Characters are read in machine specific endianness.

If the provided buffer is too small for the codepoint an exception is raised.

Parameters:

codepoint

The decoded codepoint is written to this variable.

Returns:

Number of bytes read to decode the codepoint.

staticdecode(buffer:View<UInt8>):String

Decodes all bytes in the buffer into a string. An empty string is returned if the buffer is empty.

staticencode(string:String, buffer:View<UInt8>):Int64

staticencode(codepoint:Char32, buffer:View<UInt8>):Int

Encodes all characters in the string to UTF-16 bytes. Endianness of the characters are machine specific.

If the provided buffer is too small to fit the encoded data an exception is thrown and no data is written.

Parameters:

string

String to encode.

buffer

Buffer bytes will be witten into.

Returns:

Number of bytes written into the buffer.

staticgetByteCount(codepoint:Char32):Int

staticgetByteCount(string:String):Int64

Calculates the number of bytes needed to encode the given codepoint.

staticgetCharCount(codepoint:Char32):Int

staticgetCharCount(string:String):Int64

Calculates the number of characters needed to encode the given codepoint.

staticisEncoded(string:String):Bool

Returns if the provided string is UTF-16 encoded.