fast.cstring

Converts between UTF-8 and UTF-16.

Members

Functions

asString
inout(char)[] asString(inout(char*) ptr)

Returns the given ptr up to but not including the \0 as a char[].

charPtr
immutable(char)* charPtr()

char* version of wcharPtr. Basically it appends a \0 to the input. The function uses malloc for strings of lengths 1024 and above.

charPtr
auto charPtr(void* buffer)

char* version of wcharPtr. Basically it appends a \0 to the input. The function uses malloc for strings of lengths 1024 and above.

charPtr
StackBufferEntry!char charPtr(const(char)[] str, SB sb)

This overload allocates the required memory from an existing stack buffer.

string2wstring
wchar[] string2wstring(char[] src, wchar* dst)

Converts a string to a wstring using a buffer provided by the user. To get the buffer requirements call wstringSize on your source buffer.

string2wstringSize
size_t string2wstringSize(char[] src)

Calculates the required buffer size in bytes for a string to wchar[] conversion. Room for a terminating '\0' is included.

wcharPtr
auto wcharPtr(void* buffer)
immutable(wchar)* wcharPtr()

Replaces std.utf.toUTFz with a version that uses the stack as long as the required bytes for the output are <= 1k. Longer strings use malloc to create a buffer for the conversion. It is freed at least at the end of the scope.

wstring2string
char[] wstring2string(wchar[] src, char* dst)

Converts a wstring to a string using a buffer provided by the user. To get the buffer requirements call stringSize on your source buffer.

wstring2stringSize
size_t wstring2stringSize(wchar[] src)

Calculates the required buffer size in bytes for a wstring to char[] conversion. Room for a terminating '\0' is included.

Meta