如何将特殊字符(0x80..0x9F)写入Windows控制台? [英] How do I write special characters (0x80..0x9F) to the Windows console?

查看:271
本文介绍了如何将特殊字符(0x80..0x9F)写入Windows控制台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要这个代码:

  System.Console.Out.WriteLine(œil); 

显示œil c> $

$ <$> 默认设置为西欧(DOS) CodePage 设置为850和 WindowsCodePage 设置为1252)。字符集包含特殊的OE和oe diphtong(如可在维基百科上的文章在Windows-1252上看到的),但不知何故,我怀疑 ISO-8859- 1 set get aband / replaced。



字符如â ç等正确显示在控制台上,但扩展的0x80 ... 0x9F范围内的任何字符都不是。



如何



<$>

解决方案

p $ p> Console.OutputEncoding = System.Text.Encoding.UTF8;
System.Console.Out.WriteLine(œil);

不要忘记为您的控制台窗口选择支持所需字符的字体。这是我使用Consolas字体的控制台窗口的屏幕截图。




I would like to have this code:

System.Console.Out.WriteLine ("œil");

display œil instead of oil as it does in my test program.

The Console.OutputEncoding is set by default to Western European (DOS) (CodePage set to 850 and WindowsCodePage set to 1252) on my system. The character set contains the special OE and oe diphtongs (as can be seen on the Wikipedia article on Windows-1252) but somehow, I suspect that the characters not found in the ISO-8859-1 set get discarded/replaced.

Characters such as â, ç, etc. get properly displayed on the console, but any character in the extended 0x80 ... 0x9F range are not.

How can I properly display them on the console?

解决方案

Like this:

Console.OutputEncoding = System.Text.Encoding.UTF8;
System.Console.Out.WriteLine("œil");

Don't forget to select a font for your console window that supports the characters you need. This is a screen shot of my console window using the Consolas font.

这篇关于如何将特殊字符(0x80..0x9F)写入Windows控制台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆