Console.OutputEncoding相应设置,但控制台仍然打印geeberish [英] Console.OutputEncoding set accordingly but Console still prints geeberish

查看:1417
本文介绍了Console.OutputEncoding相应设置,但控制台仍然打印geeberish的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在调试我看到的字符正确。为什么Visual Studio和System.Console编码有什么不同?如何让控制台的编码比赛VS的吗?

In debug I do see the characters properly. Why do Visual Studio and System.Console encodings differ ? How to make console's encoding match VS's one ?

有几个帖子询问过类似的问题,但是我们缺乏一个明确的答案。我列出以下的所有我试过的替代品 - 没有工作

There are a couple of posts inquiring about a similar problem, but we are lacking a straightforward answer. I am listing below all the alternatives I tried - which did not work.

有些帖子提到,为了控制台正确打印出来,你需要有正确设置+控制台输出编码有支持的人品有问题设置字体。我只是找不到一个答案(如果甚至有可能)改变控制台的字体。

Some posts mention that in order to the console print them correctly, you need to have the Console output encoding properly set + have a font that supports the character set in question. I just could not find an answer (if even possible) to change the console's font.

1 .Setting Console.OutputEncoding 来UTF8或

1.Setting Console.OutputEncoding to UTF8 or to

Encoding.GetEncoding(1255);

在我的情况我处理的希伯来文字符。

In my case I am dealing with hebrew characters.

2 .Tried打印的结果

2.Tried printing the result of

Encoding.GetEncoding(1255).GetString(Encoding.Default.GetBytes(myString))

再次在调试琴弦做正确显示。是的,我已经没有太多熟悉的字符编码​​的话题,我希望这不是必需的东西这么简单,通过System.Console显示非ASCII字符。

Again, in debug the strings do display correctly. And yes, I have not much familiarity with the topic of character encoding, and I am hoping this is not required for something as simple as this, displaying non-ascii characters via System.Console.

推荐答案

下面是答案,最后:

为什么Visual Studio和System.Console编码有什么不同?怎么做   控制台的编码比赛VS的吗?

Why do Visual Studio and System.Console encodings differ ? How to make console's encoding match VS's one ?

答案设置System.Console.OutputEncoding 来UTF8,统一code或任何其他你需要做的工作。如果显示不正确的字符仍然保持,问题与字体Windows命令提示符(什么在VS中我们称之为控制台)配置为使用不支持的字符集,你试图显示。在很短的,的问题是那么的字体

Answer: Setting System.Console.OutputEncoding to UTF8, Unicode or whatever else you need does the job. If the characters still keep being displayed incorrectly, the problem is with the font windows command prompt (what in VS we call Console) is configured to use not supporting the character set you are trying to display. In a short, the problem is then the font.

我只是找不到一个答案(如果甚至有可能)改变   控制台的字体。

I just could not find an answer (if even possible) to change the console's font.

答: 这里的一个伟大的链接,将引导您完成这样的任务。

Answer: Here's a great link that will walk you through accomplishing such task.

在命令提示符下添加额外的字体显示之后,的回答显示了如何选择新添加的字体截图。

After adding additional fonts for display in the command prompt, this answer shows screenshots of how do select a newly added font.

在很短的,如果你在这个职位结束了,并试图让一些非ASCII字符集被打印在命令提示符窗口中的解决方案是设置System.Console .OuputEncoding据此+确保配置要使用命令提示符的字体支持的字符集,你正在处理

In a short, if you ended up in this post and are trying to have some non-ascii character set being printed in a command prompt window, the solution is setting System.Console.OuputEncoding accordingly + making sure the font configured to be used by your command prompt supports the character set you are dealing with.

这篇关于Console.OutputEncoding相应设置,但控制台仍然打印geeberish的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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