digitalmars.D.learn - Asian characters are not printed propely in console
- Jun <blings naver.com> Jan 04 2011
- "Vladimir Panteleev" <vladimir thecybershadow.net> Jan 04 2011
- bearophile <bearophileHUGS lycos.com> Jan 05 2011
- torhu <no spam.invalid> Jan 05 2011
I'm sorry for posting in the wrong place. I attached screenshot of my code and the result. As you can see, Korean letters get changed after compilation. This problem doesn't happen with user input(from readln() method). Should I use different type and prefix or suffix similary to C++?
Jan 04 2011
On Tue, 04 Jan 2011 11:47:32 +0200, Jun <blings naver.com> wrote:Should I use different type and prefix or suffix similary to C++?
Place the following code anywhere at the top level in your program: version(Windows) { import std.c.windows.windows : SetConsoleCP, SetConsoleOutputCP; static this() { SetConsoleCP(65001); SetConsoleOutputCP(65001); } } This code should really be in the standard library, I think. -- Best regards, Vladimir mailto:vladimir thecybershadow.net
Jan 04 2011
Vladimir Panteleev:This code should really be in the standard library, I think.
File a bug report, with a little patch, then :-) Bye, bearophile
Jan 05 2011
On 04.01.2011 10:47, Jun wrote:I'm sorry for posting in the wrong place. I attached screenshot of my code and the result. As you can see, Korean letters get changed after compilation. This problem doesn't happen with user input(from readln() method). Should I use different type and prefix or suffix similary to C++?
If you save the file as utf-8, and set the console to CP 65001 (which is utf-8), it should work. Providing your console font suppports the characters, of course. You can add the suffixes 'w' or 'd' to get utf-16 or utf-32, respectively. But then you need to save the file in that encoding, and change the console code page accordingly. It all has to match up. But I would expect it to work with other character sets too, as long as the file encoding and the console match.
Jan 05 2011









bearophile <bearophileHUGS lycos.com> 