www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - std.string.toString(wchar* s)

reply Geoff Hickey <ardri comcast.net> writes:
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 -
Mar 27 2006
parent =?ISO-8859-1?Q?Julio_C=E9sar_Carrascal_Urquijo?= writes:
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.
Mar 28 2006