how to localize console and GUI apps in Windows

thedeemon dlang at thedeemon.com
Wed Jan 3 09:11:32 UTC 2018


On Wednesday, 3 January 2018 at 06:42:42 UTC, Andrei wrote:
>> AFAIK, Windows GUI have no ANSI/OEM problem.
>> You can use Unicode.
>
> Partly, yes. Just for a test I tried to "russify" the example 
> Windows GUI program that comes with D installation pack 
> (samples\d\winsamp.d). Window captions, button captions, 
> message box texts written in UTF8 all shows fine. But direct 
> text output functions CreateFont()/TextOut() render all 
> Cyrillic from UTF8 strings into garbage.

Windows API contains two sets of functions: those whose names end 
with A (meaning ANSI), the other where names end with W (wide 
characters, meaning Unicode). The sample uses TextOutA, this 
function that expects 8-bit encoding. Properly, you need to use 
TextOutW that accepts 16-bit Unicode, so just convert your UTF-8 
D strings to 16-bit Unicode wstrings, there are appropriate 
conversion functions in Phobos.



More information about the Digitalmars-d-learn mailing list