string concatenation
Stefan
stefan at schuerger.com
Sun Apr 8 16:06:02 PDT 2012
On Sunday, 8 April 2012 at 05:08:15 UTC, dnewbie wrote:
> wchar[100] v;
> v[0] = 'H';
> v[1] = 'e';
> v[2] = 'l';
> v[3] = 'l';
> v[4] = 'o';
> v[5] = 0;
> string s = toUTF8(v) ~ ", world!";
> MessageBoxA(null, s.toStringz, "myapp", MB_OK);
Hint: You normally don't use fixed-length arrays in D - unless
there is a model world restriction, such as in
class Car{
Tire[4] tires;
...
}
So if you really want to have UTF16 conversion and back (which I
guess you don't), your code would be:
wchar[] v = "Hello"w;
string s = toUTF8(v) ~ ", world!";
MessageBoxA(null, s.toStringz, "myapp", MB_OK);
What you probably want is
string v = "Hello";
string s = v ~ ", world!";
MessageBoxA(null, s.toStringz, "myapp", MB_OK);
Cheers,
Stefan
More information about the Digitalmars-d-learn
mailing list