In our application, we receive text files (.txt, .csv, etc.) from diverse sources. When reading, these files sometimes contain garbage, because the
.txt
.csv
As addon to ITmeze post, I've used this function to convert the output of C# port for Mozilla Universal Charset Detector
private Encoding GetEncodingFromString(string codePageName) { try { return Encoding.GetEncoding(codePageName); } catch { return Encoding.ASCII; } }
MSDN