I'm reading a file using:
var source = File.ReadAllText(path);
and the character ?
wasn't being loaded correctly.
Then, I changed it to:
var source = File.ReadAllText(path, Encoding.UTF8);
and nothing.
I decided to try using
var source = File.ReadAllText(path, Encoding.Default);
and it worked perfectly.
Then I debugged it and tried to find which Encoding did the trick, and I found that it was UTF-7
.
What I want to know is:
Is it recommended to use Encoding.Default
, and can it guarantee all the characters of the file will be read without problems?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…