EncodingScheme

Abstract base class of all encoding schemes

Members

Functions

canEncode
bool canEncode(dchar c)

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

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

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

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

Decodes a single code point.

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

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

encodedLength
size_t encodedLength(dchar c)

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

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

Returns the length of the first encoded sequence.

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

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

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

Returns true if the array is encoded correctly

names
string[] names()

Returns an array of all known names for this encoding scheme

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

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

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.

toString
string toString()

Returns the standard name of the encoding scheme

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

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

Properties

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.

Static functions

create
EncodingScheme create(string encodingName)

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

register
void register()

Registers a subclass of EncodingScheme.

Meta