突出的焦炭 [英] Accentuated char

查看:70
本文介绍了突出的焦炭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


StreamReader类的方法Read()没有读过加重的

字符。当文件中出现一个突出的字符时,Read()跳过

并读取下面的字符。想念什么?


感谢您的帮助


P. Cloup

解决方案

Pascal Cloup< pc **** @ biogesta.fr>写道:

StreamReader类的方法Read()没有读出突出的
字符。当文件中出现突出显示的字符时,Read()跳过它并读取以下字符。缺少什么?




很可能你的编码错误了。当一切正确时,肯定会*读取

重音字符。你是如何建造你的StreamReader的?b $ b,你的数据源是什么?


-

Jon Skeet - < ; sk *** @ pobox.com>
http://www.pobox .com / ~siget

如果回复小组,请不要给我发邮件


Hello Jon

" Jon Skeet [C#MVP]" < SK *** @ pobox.com>一个écritdansle message de

新闻:MP ************************ @ msnews.microsoft.c om .. 。

Pascal Cloup< pc **** @ biogesta.fr>写道:

StreamReader类的方法Read()没有读出突出的
字符。当文件中出现突出显示的字符时,Read()
跳过它并读取以下字符。想念什么?
你可能有错误的编码。当一切正确时,它肯定会*读取重音字符。你是如何构建StreamReader的,以及你的数据源是什么?




实际上我创建了一个文件流对象和2个流对象: br />
itsFileStream = File.Open(itsPath,FileMode.Open);


itsBinaryReader = new BinaryReader(itsFileStream,Encoding.ASCII);

//也许问题在这里,但我也尝试UTF8

itsStreamReader = new StreamReader(itsFileStream);


取决于性质文件(二进制或文本)我使用2

流之一,但2仍保持打开(??);如果文件是文本,我需要BinaryStream来确定

。所有工作都很好,除了突出的字符

(éàè)被跳过。


有什么想法吗?


提前致谢,


Pascal Cloup
-
Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet
如果回复小组,请不要给我发邮件



Pascal Cloup< pc **** @ biogesta.fr>写道:

你可能有错误的编码。当一切正确时,它肯定会*读取重音字符。你是如何构建StreamReader的,以及你的数据源是什么?
实际上我创建了一个文件流对象和2个流对象:
itsFileStream = File.Open(itsPath,FileMode.Open);




它的BinaryReader(newFileStream,Encoding .ASCII);
//问题可能在这里,但我也尝试UTF8











这听起来不错。同一个

流的两个读者肯定会引起问题。

根据文件的性质(二进制或文本)我使用其中一个2
溪流,但2仍然开放(??);我需要BinaryStream来确定文件是否是文本。一切正常,除了突出的字符
(éàè)被跳过。




我认为重点是它绝对是一个文本文件 - 否则

你为什么要读它呢? *任何*文件都可以是文本文件,但是

取决于使用什么编码来表示该文件的含义。


你需要知道该文件的编码是什么,并指定到

StreamReader - 忽略BinaryReader。


-

Jon Skeet - < sk *** @ pobox.com>
http:// www .pobox.com / ~siget

如果回复小组,请不要给我发邮件


Hello,

The methods Read() of the class StreamReader don''t read the accentuated
characters. When an accentuated character is present in a file, Read() skip
it and read the following character. Missing something?

Thanks for help

P. Cloup

解决方案

Pascal Cloup <pc****@biogesta.fr> wrote:

The methods Read() of the class StreamReader don''t read the accentuated
characters. When an accentuated character is present in a file, Read() skip
it and read the following character. Missing something?



Chances are you''ve got the wrong encoding. It certainly *does* read
accented characters when everything is correct. How are you
constructing your StreamReader, and what''s your data source?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Hello Jon
"Jon Skeet [C# MVP]" <sk***@pobox.com> a écrit dans le message de
news:MP************************@msnews.microsoft.c om...

Pascal Cloup <pc****@biogesta.fr> wrote:

The methods Read() of the class StreamReader don''t read the accentuated
characters. When an accentuated character is present in a file, Read() skip it and read the following character. Missing something?
Chances are you''ve got the wrong encoding. It certainly *does* read
accented characters when everything is correct. How are you
constructing your StreamReader, and what''s your data source?



In fact i create a file stream object and 2 stream objects:
itsFileStream = File.Open( itsPath , FileMode.Open );

itsBinaryReader = new BinaryReader( itsFileStream , Encoding.ASCII );
// Perhaps the problem is here but i also try UTF8

itsStreamReader = new StreamReader( itsFileStream );

Depending of the nature of the file (binary or text) i use one of the 2
streams , but the 2 remain open (??); i need the BinaryStream to determine
if the file is text or not. All works fine except for accentuated characters
(é à è) which are skipped.

Any idea?

Thanks in advance,

Pascal Cloup
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too



Pascal Cloup <pc****@biogesta.fr> wrote:

Chances are you''ve got the wrong encoding. It certainly *does* read
accented characters when everything is correct. How are you
constructing your StreamReader, and what''s your data source?
In fact i create a file stream object and 2 stream objects:
itsFileStream = File.Open( itsPath , FileMode.Open );

itsBinaryReader = new BinaryReader( itsFileStream , Encoding.ASCII );
// Perhaps the problem is here but i also try UTF8

itsStreamReader = new StreamReader( itsFileStream );



That sounds like a bad idea to start with. Two readers on the same
stream is bound to cause problems.
Depending of the nature of the file (binary or text) i use one of the 2
streams , but the 2 remain open (??); i need the BinaryStream to determine
if the file is text or not. All works fine except for accentuated characters
(é à è) which are skipped.



I thought the point was that it was definitely a text file - otherwise
why are you trying to read it? *Any* file can be a text file, but it
depends on what encoding is being used as to what that file means.

You need to know what encoding the file is in, and specify that to the
StreamReader - ignore the BinaryReader.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


这篇关于突出的焦炭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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