Asp.net encoding
I have a C#.net console ap开发者_如何学编程plication which reads data from a text file and updates it to the database. The file will have Scandinavian characters and other language characters. This is how I read the file in my app
using (StreamReader sr = new StreamReader(openFileDialog1.FileName))
but this scrabled the output charcters
I tried using utf8 to read the file but it was returning characters similar to chinese.
using (StreamReader sr = new StreamReader(openFileDialog1.FileName,Encoding.UTF8))
Why is this not working?
Then I tried using the following and its returning the correct characters.
using (StreamReader sr = new StreamReader(openFileDialog1.FileName,Encoding.GetEncoding(1252)))
My question is will the last method help in converting all the characters from different languages or only scandinavain charcters.
I dont have much idea on encoding if someone can explain me how it works. It would be very helpful.
Here is The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)
About 1252 read here: http://en.wikipedia.org/wiki/ISO_8859-1 . This encoding covers most European languages (with latin script), including but limited to Scandinavian.
精彩评论