EncodingSchemeUtf16Native

EncodingScheme to handle UTF-16 in native byte order

This scheme recognises the following names: "UTF-16LE" (little-endian architecture only) "UTF-16BE" (big-endian architecture only)

class EncodingSchemeUtf16Native : EncodingScheme {
version(LittleEndian)
const
enum string NAME;
version(BigEndian)
const
enum string NAME;
}

Inherited Members

From EncodingScheme

register
void register()

Registers a subclass of EncodingScheme.

create
EncodingScheme create(string encodingName)

Obtains a subclass of EncodingScheme which is capable of encoding and decoding the named encoding scheme.

toString
string toString()

Returns the standard name of the encoding scheme

names
string[] names()

Returns an array of all known names for this encoding scheme

canEncode
bool canEncode(dchar c)

Returns true if the character c can be represented in this encoding scheme.

encodedLength
size_t encodedLength(dchar c)

Returns the number of ubytes required to encode this code point.

encode
size_t encode(dchar c, ubyte[] buffer)

Encodes a single code point into a user-supplied, fixed-size buffer.

decode
dchar decode(const(ubyte)[] s)

Decodes a single code point.

safeDecode
dchar safeDecode(const(ubyte)[] s)

Decodes a single code point. The input does not have to be valid.

replacementSequence
immutable(ubyte)[] replacementSequence [@property getter]

Returns the sequence of ubytes to be used to represent any character which cannot be represented in the encoding scheme.

isValid
bool isValid(const(ubyte)[] s)

Returns true if the array is encoded correctly

validLength
size_t validLength(const(ubyte)[] s)

Returns the length of the longest possible substring, starting from the first element, which is validly encoded.

sanitize
immutable(ubyte)[] sanitize(immutable(ubyte)[] s)

Sanitizes an array by replacing malformed ubyte sequences with valid ubyte sequences. The result is guaranteed to be valid for this encoding scheme.

firstSequence
size_t firstSequence(const(ubyte)[] s)

Returns the length of the first encoded sequence.

count
size_t count(const(ubyte)[] s)

Returns the total number of code points encoded in a ubyte array.

index
ptrdiff_t index(const(ubyte)[] s, size_t n)

Returns the array index at which the (n+1)th code point begins.

Meta