CMan <(E-Mail Removed)> wrote:
> I am reading a text file using a StreamReader in C# but the reader is unable
> to handle some of the characheters.
>
> Using the default encoding the program cannot handle accented characters. I
> tried opening the file using other encodings e.g. UTF7.
> UTF7 fixed the accents but cannot hadle the plus sign x2B. I am also having
> problems with the Euro symbol x80 and quote x92.
If your file is using 0x80 for the Euro symbol, that should help to
narrow it down...
Have you tried using Encoding.Default? That's not the same as the
default encoding for StreamReader when you don't specify an encoding.
(It's the default encoding for your computer, instead.)
> How do I read this file correctly?
By specifying the correct encoding.
> Is this problem caused by the encoding?
Almost certainly.
> Is there a way to determine the file's encoding at runtime?
There are ways you can try to guess it heuristically, but nothing
foolproof.
> How else can I find out the encoding?
Well, what generated this text file to start with?
See
http://www.pobox.com/~skeet/csharp/unicode.html for more
information.
--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too