|
Archives
D Programming
digitalmars.Ddigitalmars.D.bugs digitalmars.D.dtl digitalmars.D.ide digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger D.gnu D C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript electronics |
digitalmars.D.learn - How to print Chinese characters in console in window XP?
In DMD2030 I just found that Chinese characters the like can not print properly
into console.
//Below code does not show output properly in windows console:
void main()
{
wstring country="中国";
writefln(country);
}
Is this an OS issue or is there any way to reach the goal?
Thanks in advance.
Jun 27 2009
On Sat, Jun 27, 2009 at 5:53 AM, Sam Hu<samhudotsamhu gmail.com> wrote:In DMD2030 I just found that Chinese characters the like can not print pr= Jun 27 2009
Jarrett Billingsley Wrote:On Sat, Jun 27, 2009 at 5:53 AM, Sam Hu<samhudotsamhu gmail.com> wrote: Jun 27 2009
and I start cmd.exe with /u switch. I also tried being inspired by below article: http://www.codeproject.com/KB/cpp/unicode_console_output.aspx?display=Print but unfortunately also failed. Jun 27 2009
Sorry to have to disappoint you, but Chinese output to a Windows console is non-trivial if not entirely impossible (you'd probably have to ask someone using a Chinese Windows version for a definitive answer). Your approach will work for more common unicode characters, like eg. the greek alphabet, the problem is that the fonts included with your standard Windows just don't come with Chinese glyphs. In theory you *could* hack the registry to enable different fonts for the console (HKLM/SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont, add a string entry named 00, 000, 000 etc. and your desired font as value), but you'd still have to find a font including Chinese glyphs which works for this purpose. There are fonts like for example GNU unifont and something called SimSun from Micro$oft which contain these glyphs, but to my knowledge none these work in the console. So the short answer is no, afaik there isn't any practical way to get Chinese output in the Windows console. Jun 27 2009
Elrood wrote:Sorry to have to disappoint you, but Chinese output to a Windows console is non-trivial if not entirely impossible (you'd probably have to ask someone using a Chinese Windows version for a definitive answer). Jun 27 2009
On Sat, 27 Jun 2009 16:13:03 -0600, Rainer Deyke wrote:Elrood wrote:Sorry to have to disappoint you, but Chinese output to a Windows console is non-trivial if not entirely impossible (you'd probably have to ask someone using a Chinese Windows version for a definitive answer). Jun 27 2009
Derek Parnell wrote:C:\temp>chcp 932 Invalid code page C:\temp>chcp 65001 Active code page: 65001 It seems that my Windows XP doesn't know about CP932. Jun 27 2009
Rainer Deyke:In Python, unicode text output just plain works. Jun 27 2009
Dear All:
Thank you so much for all your help!
Yes,I am using xp+sp3 Chinese version and can print Chinese font in the console
in C++ program:
#include <iostream>
int main(int argc,char* argv[])
{
std::cout<<"中国"<<std::endl;
return 0;
}
Jun 27 2009
Elrood wrote:While it certainly wasn't my intent to spread false info, nor to defend D or sidetrack from its bugs, I cannot confirm that unicode output *just plain works*, neither with Python, and I'd be highly interested in more info on how you got it to work. Jun 28 2009
Rainer Deyke: Thanks for your clarification. The problem is that, unless you set up your system to use Chinese for every non-unicode-ready application, systemwide and for all users, you will not get Chinese character output in the Windows console. The downside is that setting up your OS in such a way tends to render the user interface of a lot of other applications unusable if Chinese isn't your everyday language. For a lot of us this isn't very practicable, eg. having my German umlauts replaced with Chinese glyphs isn't exactly what I have dreamed of all my life. That's what I meant with the changes not being trivial, and your response sounded a bit like I was talking nonsense and getting it to work was a piece of cake, and I naturally was curious whether there was a simple solution. While being a bit disappointing, thanks for straightening out that this isn't the case. Nonetheless there apparently is a bug here if D/Phobos with its supposed unicode support isn't capable of producing output which is possible with Python or even olde C++. Jun 29 2009
On Sat, Jun 27, 2009 at 10:55 AM, Sam Hu<samhudotsamhu gmail.com> wrote:and I start cmd.exe with /u switch. I also tried being inspired by below article: http://www.codeproject.com/KB/cpp/unicode_console_output.aspx?display=Print but unfortunately also failed. Jun 27 2009
|