dil.Unicode

Members

Aliases

toUTF16
alias toUTF16 = convertString!(char, wchar)

Converts a UTF-8 string to a UTF-16 string.

toUTF32
alias toUTF32 = convertString!(char, dchar)

Converts a UTF-8 string to a UTF-32 string.

toUTF8
alias toUTF8 = convertString!(wchar, char)

Converts a UTF-16 string to a UTF-8 string.

Enums

UTF16Error
enum UTF16Error

Enumeration of errors related to decoding UTF-16 sequences.

UTF8Error
enum UTF8Error

Enumeration of errors related to decoding UTF-8 sequences.

Functions

convertString
B[] convertString(const(A)[] str)

Converts a string from type A to B.

decode
dchar decode(cstring str, ref size_t index)

Decodes a character from str at index.

decode
dchar decode(ref cchar* ref_p, cchar* end)

Decodes a character starting at ref_p.

decode
dchar decode(cwstring str, ref size_t index)

Decodes a character from a UTF-16 sequence.

decode
dchar decode(ref cwchar* p, cwchar* end)

Decodes a character from a UTF-16 sequence.

decode
dchar decode(ref cwchar* p)

Decodes a character from a zero-terminated UTF-16 string.

decodeUnicodeAlpha
dchar decodeUnicodeAlpha(ref cchar* ref_p, cchar* end)

Advances ref_p only if this is a valid Unicode alpha character.

encode
void encode(ref char[] str, dchar c)

Encodes c and appends it to str.

encode
char[] encode(char* p, dchar c)

Writes the encoded character to a buffer that must be of sufficient length.

encode
void encode(ref wchar[] str, dchar c)

Encodes c and appends it to str.

isLeadByte
bool isLeadByte(ubyte b)
isNoncharacter
bool isNoncharacter(dchar d)

There are a total of 66 noncharacters.

isTrailByte
bool isTrailByte(ubyte b)
isUnicodeAlpha
bool isUnicodeAlpha(cchar* p, cchar* end)

Returns true when p points to a valid Unicode alpha character.

isValidChar
bool isValidChar(dchar d)
isValidLead
bool isValidLead(char c)
bool isValidLead(wchar c)
bool isValidLead(dchar c)
scanUnicodeAlpha
bool scanUnicodeAlpha(ref cchar* p, cchar* end)

Returns true when p points to a valid Unicode alpha character (also advances p.)

utf16Error
UTF16Error utf16Error(cwstring s, ref size_t i)
UTF16Error utf16Error(ref cwchar* p, cwchar* end)

Returns the precise error in a UTF-16 sequence.

utf8Error
UTF8Error utf8Error(cstring s, ref size_t i)
UTF8Error utf8Error(ref cchar* p, cchar* end)

Returns the precise error in a UTF-8 sequence.

Variables

ERROR_CHAR
enum dchar ERROR_CHAR;

Invalid character, returned on errors.

REPLACEMENT_CHAR
enum cdchar REPLACEMENT_CHAR;
REPLACEMENT_STR
enum cchar[3] REPLACEMENT_STR;

U+FFFD = �. Used to replace invalid Unicode characters.

Meta

Authors

Aziz Köksal

License

GPL3 $(Maturity very high)