C# System.Windows.Forms.TextBox 中未显示 Unicode 字符

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/420659/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 02:44:11  来源:igfitidea点击:

Unicode characters not showing in System.Windows.Forms.TextBox

c#user-interfaceformsunicodetextbox

提问by Sean

These characters show fine when I cut-and-paste them here from the VisualStudio debugger, but both in the debugger, and in the TextBox where I am trying to display this text, it just shows squares.

当我从 VisualStudio 调试器将它们剪切并粘贴到此处时,这些字符显示良好,但在调试器和我试图显示此文本的 TextBox 中,它只显示方块。

说明\r\n海流受季风影响,3-9 月份其流向主要向北,流速为2 节,有时达3 节;10 月至次年4 月份其流向南至东南方向,流速为2 节。\r\n注意\r\n附近有火山爆发的危险,航行时严加注意\r\n

说明\r\n海流受季风影响,3-9月份其流向主要北,流速为2节,有时达3节;10月至次年4月份其流向南至东南方向,流速为2节。\ r\n注意\r\n附近有火山爆发的危险,航行时严加注意\r\n

I thought that the TextBox supported Unicode text. Any idea how I can get this text to display in my application?

我认为 TextBox 支持 Unicode 文本。知道如何让此文本显示在我的应用程序中吗?

采纳答案by Sean

I changed from using a TextBox to using a RichTextBox, and now the characters display in the RichTextBox.

我从使用TextBox 改为使用RichTextBox,现在字符显示在RichTextBox 中。

回答by Dead account

You need to install and use a font which supports those characters. Not all fonts support all characters. the [] box character is the fonts representation of 'unsupported'

您需要安装并使用支持这些字符的字体。并非所有字体都支持所有字符。[] 框字符是“不支持”的字体表示

The textbox might be using MS Sans Serif by default, so change it to Arial or something else.

默认情况下,文本框可能使用 MS Sans Serif,因此将其更改为 Arial 或其他内容。

回答by Pratik Deoghare

I was facing similar problem.

我面临着类似的问题。

It was problem with reading file properlyand not with TextBoxcontrol.

这是与正确读取文件的问题,而不是与TextBox控制。

StreamReader reader = new StreamReader(inputFilePath, Encoding.Default, true)

Copied from THIS.

这个复制。

Works for me and that too without switching to RichTextBox.

对我有用,也不需要切换到RichTextBox.