Wednesday, August 20, 2008

StreamReader problem to read special characters and solution

StreamReader and Peek, Read, ReadBlock, ReadLine or ReadToEnd has problem to read text files with international characters like in Swedish, Finnish, German, etc.
Here are some Swedish letters that needs special treatment: Å, Ä, Ö, å, ä, ö.

What was used when I noticed this problem was:

StreamReader(Stream) 

The solution in VB.NET or C# is using something like this:

StreamReader(Stream, System.Text.Encoding.Default)

For Chinese or Japanese System.Text.Encoding.Unicode is probably needed.

An example of a large application that has problems is Google Blogger that sends email copies of comments and say a comment is ÅÄÖåäö what is emailed is ÅÄÖåäö


Some of the latest blog posts

Subscribe to RSS headline updates from:
Powered by FeedBurner