Link to home
Start Free TrialLog in
Avatar of JaimeH
JaimeH

asked on

Streamreader interpreting special characters incorrectly

Hi all,

I'm using a streamreader to read a txt file in VB .NET, (for conversion of the data it contains to XML) and am coming up against the problem that the streamreader doesn't interpret special characters correctly:  "á" is interpreted as "ý", while German vowels with Umlauts ("ä, ö, ü") are interpreted in &...; form (ä, ö ü, respectively).

The question is: Can I change the encoding the streamreader uses so that it interrprets the text correctly?"

Thanks very much in advance

JaimeHy
ASKER CERTIFIED SOLUTION
Avatar of vilimed
vilimed

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vilimed
vilimed

reader.CurrentEncoding = System.Text.Encoding.GetEncoding(1250);
sorry in vb
Dim sr As StreamReader = New StreamReader("TestFile.txt", System.Text.Encoding.GetEncoding(1250))
Avatar of JaimeH

ASKER

Thanks vilimed,

Your answer was simple, taciturn and most of all it worked.

I'm much obliged 8 [tips hat]
Avatar of JaimeH

ASKER

Isn't 1250 Central European?  I used 1252 in the end.
yes 1250 is Central European. I am from Central European.-))
What flavour of central European?  I'm a westerner myself (about as far west as you can get without going for a swim in the Atlantic (Irish).

Thanks again!

Jaimeh