How can I detect the encoding/codepage of a text file

In our application, we receive text files (.txt, .csv, etc.) from diverse sources. When reading, these files sometimes contain garbage, because the files where created in a different/unknown codepage. Is there a way to (automatically) detect the codepage of a text file? The detectEncodingFromByteOrderMarks, on the StreamReader constructor, works for UTF8 and other unicode marked … Read more