Streamreader Codepage Problems

I'm having some problems with a text file i have received from a customer, that I need to load into a dataset with a Streamreader.

I have tried to use the Encoding object, but the streamreader still doesn't read special characters correctly.

If i open the textfile in Notepad and save it as Unicode, it does not seem to matter which Encoding i tell the streamreader to use, it comes in correctly regardless.

If i do not change the file in notepad, the same scenario applies, it does not seem to matter which encoding i use, it still comes in WRONG !  :(

Please excuse my ignorance, this is my first try with codepages and encoding, and im under deadline pressure. Sorry for lack of any important info, please ask me what need to be asked.

Thanks 1.000.000 in advance !

Cheers
jeschrperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sognoctCommented:
ASCII is a 7-bit encoding and has not all characters.  You must discover what kind of  encoding has your file and tell the StreamReader. By default it uses UTF8Encoding.

Try
StreamReader sr = new StreamReader("foo.txt",System.Text.Encoding.Default);

That will us your computer's regional settings to get the current code page, or figure out what code page is used for your file and specify it.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jeschrperAuthor Commented:
Thank you for input. I am an idiot, problem caused by bad code :(
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.