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.

  1. auto wcharPtr(void* buffer)
    @nogc nothrow
    wcharPtr
    (
    alias str
    )
    (
    void* buffer = string2wstringSize(str) <= allocaLimit ? alloca(string2wstringSize(str)) : null
    )
  2. immutable(wchar)* wcharPtr()

Parameters

str

The source string to convert.

Examples

string text = "Hello, world!";
WinApiW(wcharPtr!text);

See Also

toWstring

Meta