First, let's see the code:
//The encoding of utf8.txt is UTF-8 StreamReader reader = new StreamReader(@"C:\\utf8.txt", Encoding.UTF8, true); while (reader.Peek() > 0) { //What is the encoding of lineFromTxtFile? string lineFromTxtFile = reader.ReadLine(); }
As Joel said in his famous article :
If you have a string in memory, in a file, or in an email message, you need to know what encoding it is in, or you cannot interpret or display it correctly. "
So here is my question: what is the encoding of the line lineFromTxtFile string? UTF-8 (because it is from a text file encoded in UTF-8)? or UTF-16 (since the string in .NET is "Unicode" (UTF-16))?
Thanks.
source share