文字编码 [英] Text encodings
问题描述
我正在使用StreamReader从普通的txt文件中读取一些文本
然后将其显示在文本框中。
当我看在记事本和我的程序中的文本文件中,文本看起来很乱,当我在wordpad中查看它的间距是正确的并且
没有有趣的字符。
如何确保使用正确的文本编码,以便文件正确显示
?
any帮助赞赏。
-
Eps
I am using the StreamReader to read in some text from a plain txt file
and then display it in a text box.
When I look at the text file in notepad and my program the text looks
all messed up, when I look at it in wordpad the spacing is correct and
there are no funny charcters.
How can I make sure the right text encoding is used so the file displays
properly ?
any help appreciated.
--
Eps
推荐答案
Andy Burchill写道:
Andy Burchill wrote:
我使用StreamReader从普通的txt
文件中读取一些文本,然后将其显示在文本框中。
我看看记事本中的文本文件和我的程序文本看起来都搞砸了,当我在wordpad中查看它的间距是正确的
并且没有有趣的字符。
除了那些使用允许它们识别的前导码(例如带有BOM或UTF-16的UTF-8)的编码外,还有'''''''''''''''''''''''''''''''''''''没有好办法
识别正确的编码,因此应用程序需要猜测。似乎
记事本猜错了;-)
如何确保使用正确的文本编码以使文件正确显示?
I am using the StreamReader to read in some text from a plain txt
file and then display it in a text box.
When I look at the text file in notepad and my program the text looks
all messed up, when I look at it in wordpad the spacing is correct
and there are no funny charcters.
Save for those encodings, which use preambles that allow them to be
identified (e.g. UTF-8 with BOM or UTF-16), there''s no good way to
identify the correct encoding, so applications need to guess. Seems
Notepad is guessing wrong ;-)
How can I make sure the right text encoding is used so the file
displays properly ?
傻回答:使用正确的编码。如果你想创建一个支持多种编码的
应用程序,你必须提供一些
的方法供用户选择特定的编码。
干杯,
-
http://www.joergjooss .de
mailto:ne ******** @ joergjooss.de
Silly answer: Use the right encoding. If you want to create an
application that supports multiple encodings, you have to provide some
means for the user to select a specific encoding.
Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
愚蠢的回答:使用正确的编码。如果你想创建一个支持多种编码的
应用程序,你必须提供一些
手段供用户选择特定的编码。
干杯,
Silly answer: Use the right encoding. If you want to create an
application that supports multiple encodings, you have to provide some
means for the user to select a specific encoding.
Cheers,
谢谢你,找出
文本文件正在使用哪种编码的最简单的方法是什么?,我在我的程序中尝试了所有可用的编码
但没有正确显示。
-
Eps
thanks for that, what is the esiest way to find out which encoding a
text file is using ?, i tried all the availiable encodings in my program
but none displayed properly.
--
Eps
Andy Burchill< bi ******** @ microsoft.com>写道:
Andy Burchill <bi********@microsoft.com> wrote:
谢谢你,找出
文本文件正在使用哪种编码的最简单的方法是什么?,我在我的程序中尝试了所有可用的编码
但没有正确显示。
thanks for that, what is the esiest way to find out which encoding a
text file is using ?, i tried all the availiable encodings in my program
but none displayed properly.
我们无法保证找出文本文件的编码方式
使用。例如,任何文件都是有效的代码页1252文件,但是
并不意味着它就是你想要的。
你是绝对确定它首先是纯文本文件,
而不是单词文档?
-
Jon Skeet - < sk *** @ pobox.com>
http ://www.pobox.com/~skeet
如果回复小组,请不要给我发邮件
There''s no guaranteed way to find out which encoding a text file is
using. For instance, any file is a valid code page 1252 file, but that
doesn''t mean it''s what you want.
Are you absolutely sure it''s a plain text file in the first place,
rather than something like a word document?
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
这篇关于文字编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!