Home All Groups Group Topic Archive Search About

Detect the encoding of a stream

Author
19 Dec 2005 10:20 AM
Roshan
Hi,

Is there a way in which I can detect the encoding used while creating a
StreamReader? I have a method which receives a StreamReader as a
parameter. I want to ensure that when I do a
StreamReader.BaseStream.Seek() , I give the appropriate offset so that
encoding information/byte order marks are not read in (In case the file
uses UTF8 or Unicode encoding). Is there a standard way to do that?

Thanks,
Roshan

Author
19 Dec 2005 10:43 AM
Roshan
There's StreamReader.CurrentEncoding; Why didn't I see it earlier? :-(

Roshan

Roshan wrote:

Show quote
> Hi,
>
> Is there a way in which I can detect the encoding used while creating a
> StreamReader? I have a method which receives a StreamReader as a
> parameter. I want to ensure that when I do a
> StreamReader.BaseStream.Seek() , I give the appropriate offset so that
> encoding information/byte order marks are not read in (In case the file
> uses UTF8 or Unicode encoding). Is there a standard way to do that?
>
> Thanks,
> Roshan

AddThis Social Bookmark Button