convert string to wchar[]

Neia Neutuladh neia at
Sat May 26 17:37:15 UTC 2018

On Saturday, 26 May 2018 at 17:12:38 UTC, Dr.No wrote:
> What's D's way to do that? I need it to be mutable array of 
> wchar because a Windows function requires that.
> Alternative to go down to using pointers, which would be 
> something like:
> wchar[] w = new wchar[s.length];
> memcpy(w.ptr, s.ptr, s.length); has you covered for quite a lot of conversions:

import std.conv;
import std.stdio;
void main()
     string s = "hello world";
     wchar[] mutableUtf16 =!(wchar[]);
     mutableUtf16[0] = '☃';
     // prints ☃ello world

More information about the Digitalmars-d-learn mailing list