converting D's string to use with C API with unicode
Jack
jckj33 at gmail.com
Sat Dec 5 19:51:14 UTC 2020
So in D I have a struct like this:
>struct ProcessResult
>{
> string[] output;
> bool ok;
>}
in order to use output from C WINAPI with unicode, I need to
convert each string to wchar* so that i can acess it from C with
wchar_t*. Is that right or am I missing anything?
>struct ProcessResult
>{
> string[] output;
> bool ok;
>
> C_ProcessResult toCResult()
> {
> auto r = C_ProcessResult();
> r.ok = this.ok; // just copy, no conversion needed
> foreach(s; this.output)
> r.output ~= cast(wchar*)s.ptr;
> return r;
> }
>}
>version(Windows) extern(C) export
>struct C_ProcessResult
>{
> wchar*[] output;
> bool ok;
>}
More information about the Digitalmars-d-learn
mailing list