www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to correctly display accented characters at the Windows prompt?

reply Cleverson Casarin Uliana via Digitalmars-d-learn writes:
Hello, when I run a compiled Windows executable at the console,
letters outside the ascii range such as ç and ã do not display
propperly. Is there any d function to change the console code page on
the fly? My Windows console code page, which is for Brazilian
Portuguese, is at 850. Perhaps an alternative would be to convert d
strings from Unicode to the 850 code page on the fly.

Thanks,
Cleverson
Oct 10 2016
parent reply John C <johnch_atms hotmail.com> writes:
On Monday, 10 October 2016 at 14:14:08 UTC, Cleverson Casarin 
Uliana wrote:
 Hello, when I run a compiled Windows executable at the console, 
 letters outside the ascii range such as ç and ã do not display 
 propperly. Is there any d function to change the console code 
 page on the fly? My Windows console code page, which is for 
 Brazilian Portuguese, is at 850. Perhaps an alternative would 
 be to convert d strings from Unicode to the 850 code page on 
 the fly.

 Thanks,
 Cleverson
Call SetConsoleOutputCP(CP_UTF8).
Oct 10 2016
next sibling parent Cleverson Casarin Uliana via Digitalmars-d-learn writes:
Hello John and all, how do you search for a given function to see
where it is defined/declared? I tried to find SetConsoleOutputCP by
myself, but the search embeded in the documentation cannot find
anything in the phobos library refference, and searching the entire
site returns forum posts only.

Thanks,
Cleverson
Oct 10 2016
prev sibling next sibling parent Jonathan M Davis via Digitalmars-d-learn writes:
On Monday, October 10, 2016 13:24:09 Cleverson Casarin Uliana via Digitalmars-
d-learn wrote:
 Hello John and all, how do you search for a given function to see
 where it is defined/declared? I tried to find SetConsoleOutputCP by
 myself, but the search embeded in the documentation cannot find
 anything in the phobos library refference, and searching the entire
 site returns forum posts only.
It looks like it's in core.sys.windows.wincon; - Jonathan M Davis
Oct 10 2016
prev sibling parent reply Martin Krejcirik <mk-junk i-line.cz> writes:
 Thanks,
 Cleverson
Call SetConsoleOutputCP(CP_UTF8).
No, this may appear to to work, but in reality, it's broken. The only reliable way is to convert to the native windows codepage.
Oct 10 2016
parent reply Cleverson Casarin Uliana via Digitalmars-d-learn writes:
Hi Martin, indeed, here in my workplace Windows machine there is no
"CP_UTF_8" codepage, nor there is 65001. I was waiting to try it later
on my home machine, but since you say it's broken, then I'll need to
look for a way to convert the actual string to the 850 codepage...

Just for info, this is probably a d related bug, because the Racket
language for example has a (reencode-output-port) function, and it
Works.

Greetings,
Cleverson
Oct 10 2016
parent reply Martin Krejcirik <mk-junk i-line.cz> writes:
On Monday, 10 October 2016 at 19:31:14 UTC, Cleverson Casarin 
Uliana wrote:
 Hi Martin, indeed, here in my workplace Windows machine there 
 is no "CP_UTF_8" codepage, nor there is 65001. I was waiting to
codepage 65001 (UTF8) should be available on all modern Windows. You can try command cp 65001 in the console window (and change your font accordingly).
 Just for info, this is probably a d related bug, because the 
 Racket language for example has a (reencode-output-port) 
 function, and it Works.
I don't know know about Racket, but D's problems are related to the C runtime library. Here is what I found out: -m32 (uses DM C library): output to stdout works, but stderr is broken (corrupt accented characters, or total output freeze). https://issues.dlang.org/show_bug.cgi?id=1448 -m32mscoff and -m64 (Microsoft C runtime): broken characters and some mysterious failures. https://issues.dlang.org/show_bug.cgi?id=15761 So this leaves transcoding as the only viable solution. Luckily, there is std.windows.charset.toMBSz function you can use.
Oct 10 2016
parent Martin Krejcirik <mk-junk i-line.cz> writes:
 Windows. You can try command cp 65001 in the console window
chcp 65001
Oct 10 2016