Deprecation of toUTF16

Andre Pany via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Aug 31 09:12:05 PDT 2017


Hi,

I have some problems to find out what to use instead of the 
deprecated toUTF16 function.

I am calling a shared library written in Delphi.
While this coding is working fine (with german ü)

import std.utf: toUTF16;
wstring ws = toUTF16(s);
BSTR bStr = SysAllocStringLen(ws.ptr, cast(UINT) ws.length);

This coding fails to display the german ü correctly:

import std.utf: encode;
wchar[] ws;
s.each!(c => encode(ws, c));
BSTR bStr = SysAllocStringLen(ws.ptr, cast(UINT) ws.length);


Variable s is of type string. On delphi side WideString is used 
as type for the string.
Where is the error?

Kind regards
André


More information about the Digitalmars-d-learn mailing list