Thread overview | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
October 10, 2016 How to correctly display accented characters at the Windows prompt? | ||||
---|---|---|---|---|
| ||||
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 |
October 10, 2016 Re: How to correctly display accented characters at the Windows prompt? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Cleverson Casarin Uliana | 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).
|
October 10, 2016 Re: How to correctly display accented characters at the Windows prompt? | ||||
---|---|---|---|---|
| ||||
Posted in reply to John C | 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 |
October 10, 2016 Re: How to correctly display accented characters at the Windows prompt? | ||||
---|---|---|---|---|
| ||||
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
|
October 10, 2016 Re: How to correctly display accented characters at the Windows prompt? | ||||
---|---|---|---|---|
| ||||
Posted in reply to John C | >> 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.
|
October 10, 2016 Re: How to correctly display accented characters at the Windows prompt? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Martin Krejcirik | 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 |
October 10, 2016 Re: How to correctly display accented characters at the Windows prompt? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Cleverson Casarin Uliana | 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. |
October 10, 2016 Re: How to correctly display accented characters at the Windows prompt? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Martin Krejcirik | > Windows. You can try command cp 65001 in the console window
chcp 65001
|
Copyright © 1999-2021 by the D Language Foundation