March 28, 2006
Some time ago someone asked about including this function in Phobos:

wchar[] toString(wchar* s)
{
	return s ? s[0 .. wcslen(s)] : cast(wchar[])null;
}

(For those who haven't visited string.d: there's a char version of this,
but no wchar).

I just ran into the need for this while writing some code to process command lines in Windows programs. (There's a GetCommandLineArgvW in the API, but no "A" version, even though there's a GetCommandLineA).

Well, it seems like this function is still needed in Phobos; maybe it got forgotten before. (Ideally there should be a version that transcoded from wchars to UTF-8, too, don'tcha think?)

- Geoff Hickey -
- Sporadic D Enthusiast -
March 29, 2006
Geoff Hickey wrote:
> Some time ago someone asked about including this function in Phobos:

I asked for it ages ago and provided an implementation but didn't get approved. I support yours. The function it's still needed.