疯狂的字符编码 [英] Crazy with character encoding
问题描述
我有一个包含以下内容的文本文件:
"((^)|(。* +))§§§§§§§ §
如果我用以下内容阅读:
k = System.IO.StreamReader(" file.txt",System.Text.Encoding.ASCII );
k.readtotheend()
然后§丢失了
如果用UTF7读取
那么+丢失。
请帮助,如何将文件读入字符串以便我拥有所有
字符?
Thancs
Hi,
I have a text file with following content:
"((^)|(.* +))§§§§§§§§"
if I read it with:
k=System.IO.StreamReader( "file.txt",System.Text.Encoding.ASCII);
k.readtotheend()
Then "§" is lost
If read it with UTF7
then "+" is lost.
Please help, how can I read the file into string so that I have all
characters?
Thancs
推荐答案
嗨Zhiv,
嗯,文字不是ascii或者UTF7。很可能它是使用文件位置的默认代码表进行编码的。
尝试Encoding.Default或Encoding.GetEncoding(<编写此处的编码名称>)
-
快乐的编码!
Morten Wennevik [C#MVP]
Hi Zhiv,
Well, the text isn''t ascii or utf7. Most likely it is encoded with the default code table for the location of the file.
Try Encoding.Default or Encoding.GetEncoding(<write name of encoding here>)
--
Happy coding!
Morten Wennevik [C# MVP]
Zhiv Kurilka< Zh ********** @ LozhkaVil.cawrote:
Zhiv Kurilka <Zh**********@LozhkaVil.cawrote:
我有一个包含以下内容的文本文件:
"((^)|(。* +))§§§§§§§§"
如果我阅读它:
k = System.IO.StreamReader(" file.txt",System.Text.Encoding.ASCII);
k.readtotheend()
>
然后§丢失
I have a text file with following content:
"((^)|(.* +))§§§§§§§§"
if I read it with:
k=System.IO.StreamReader( "file.txt",System.Text.Encoding.ASCII);
k.readtotheend()
Then "§" is lost
是的,因为那不是ASCII字符。
Yes, because that isn''t an ASCII character.
如果用它读取UTF7
然后+迷路了。
If read it with UTF7
then "+" is lost.
是的,因为它不是UTF-7文件。 (UTF-7很少在外面使用
邮件。)
Yes, because it isn''t a UTF-7 file. (UTF-7 is very rarely used outside
mail.)
请帮助,如何将文件读入字符串以便我拥有所有
个字符?
Please help, how can I read the file into string so that I have all
characters?
那么,该文件的编码是什么?是什么创造的?
-
Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet 博客: http://www.msmvps.com/jon.skeet
如果回复小组,请不要给我发邮件
Well, what encoding is the file in? What created it?
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
我手工创建它,它只是一些字符。我想我已经为这个字节读取器做了b
。对吧?
" Jon Skeet [C#MVP]" < sk *** @ pobox.comschrieb im Newsbeitrag
新闻:MP ************************ @ msnews。 microsoft.c om ...
Zhiv Kurilka< Zh ********** @ LozhkaVil.cawrote:
I have created it by hand, it is just a number of characters. I suppose I
nead a bytereader for that. Right?
"Jon Skeet [C# MVP]" <sk***@pobox.comschrieb im Newsbeitrag
news:MP************************@msnews.microsoft.c om...
Zhiv Kurilka <Zh**********@LozhkaVil.cawrote:
我有一个包含以下内容的文本文件:
"((^)|(。* +))§§§§§§§§§
如果我用以下内容阅读:
k = System.IO.StreamReader(" file.txt",System.Text.Encoding.ASCII);
k.readtotheend()
然后§丢失
I have a text file with following content:
"((^)|(.* +))§§§§§§§§"
if I read it with:
k=System.IO.StreamReader( "file.txt",System.Text.Encoding.ASCII);
k.readtotheend()
Then "§" is lost
是的,因为那不是ASCII字符。
Yes, because that isn''t an ASCII character.
如果用它读取UTF7
然后+迷路了。
If read it with UTF7
then "+" is lost.
是的,因为它不是UTF-7文件。 (UTF-7很少在外面使用
邮件。)
Yes, because it isn''t a UTF-7 file. (UTF-7 is very rarely used outside
mail.)
请帮助,如何将文件读入字符串以便我拥有所有
个字符?
Please help, how can I read the file into string so that I have all
characters?
那么,该文件的编码是什么?是什么创造的?
-
Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet 博客: http://www.msmvps.com/jon.skeet
如果回复小组,请不要给我发邮件
Well, what encoding is the file in? What created it?
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
这篇关于疯狂的字符编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!