Console.Write() - 显示扩展ascii字符? [英] Console.Write() - display extended ascii chars?

查看:254
本文介绍了Console.Write() - 显示扩展ascii字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够正确显示标准的ASCII符号(最多127个),例如heart,note,你知道我的意思。我也想显示一些我可以用来绘制墙壁(如U0205),但它不工作。威尔,它的工作,但它看起来像?任何方式如何显示他们?谢谢。

I am able to correctly display the standard ASCII symbols (up to 127) like "heart", "note" you know what I mean. I would like to also display ones that I can use for drawing walls (like U0205) but it does not work..well, it works but it looks like "?". Any way how I can display them? Thank you.

推荐答案

控制台模式应用程序仅限于8位代码页编码。许多机器上的默认值是IBM437,这是与旧的IBM PC字符集匹配的代码页。您可以通过分配OutputEncoding属性来更改代码页:

Console mode apps are restricted to an 8-bit code page encoding. The default on many machines is IBM437, the code page that matches the old IBM PC character set. You can change the code page by assigning the OutputEncoding property:

        Console.OutputEncoding = Encoding.UTF8;

但现在你通常有一个字体的问题。控制台默认为终端字体,一种旧设备字体,在正确的位置具有字形以产生IBM PC字符集。没有很多可用的字体可以产生与Unicode码点匹配的正确字形。 Consolas是关于它,在Vista和Win7上可用。

But now you typically have a problem with the font. Consoles default to the Terminal font, an old device font that had glyphs in the right place to produce the IBM PC character set. There are not a lot of fonts available that can produce the proper glyphs that match the Unicode codepoints. Consolas is about it, available on Vista and Win7.

但这不是你要的,我想,我猜你真的在问老箱子绘图字符。这工作没有任何修补控制台设置,你只需要使用正确的Unicode字符。下面是一个应该能够复制和粘贴的例子:

But that's not what you are asking, I think, I'm guessing that you are actually asking about the old box drawing characters. That works without any tinkering with the console settings, you just have to use the right Unicode characters. Here's an example that ought to survive a copy-and-paste:

class Program {
    static void Main(string[] args) {
        Console.WriteLine("╒════════╕");
        Console.WriteLine("│ Hello  │");
        Console.WriteLine("│ world  │");
        Console.WriteLine("╘════════╛");
        Console.ReadLine();
    }
}

要找到这些字符,请使用Windows charmap.exe小程序。点击高级视图复选框并在搜索文本框中键入框,网格将填充框图形字符。将正确转换到控制台的第一个可用的是'\\\┌'。

To find these characters, use the Windows charmap.exe applet. Click the "Advanced view" checkbox and type "box" in the "Search for" text box, the grid will fill with the box drawing characters. The first usable one that will properly convert to the console is '\u250c'.

这篇关于Console.Write() - 显示扩展ascii字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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