std.string.toString(wchar* s)

Geoff Hickey ardri at comcast.net
Mon Mar 27 23:23:14 PST 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 -



More information about the Digitalmars-d mailing list