Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Streamreader and foreign characters

Tags:

c#

encoding

Which encoding should I use to read æ,Ø,å,ä,ö,ü etc?


1 Answers

You should use whatever the encoding of the original data is. Where are you getting the data from, and do you have information as to which encoding it's in? If you try to read it with the wrong encoding, you'll get the wrong answer: even if your encoding can handle the characters, it's going to misinterpret the binary data.

If you get to pick the encoding, then UTF-8 is usually a good bet. It's bad in terms of size if you've got a lot of far eastern characters, but otherwise good. In particular, ASCII still comes out at one byte per character.

like image 81
Jon Skeet Avatar answered Mar 15 '26 21:03

Jon Skeet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!