

So use Windows-1252 (0.9%, also know as ANSI), which is a superset of ISO-8859-1.

The second most (6.7%) used encoding is ISO-8859-1. Var streamReader = new StreamReader(stream, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true), detectEncodingFromByteOrderMarks: true) Public static string ReadAsString(this Stream stream) This works for me: public static class StreamExtension If someone is looking for a 93.9% solution. It means: If the type of the document is text/html or text/plain and there is no character encoding label on the HTTP layer or inside the document (in the text/html case) and there is no BOM at the start of the document, assume the language of the page is the one selected from the Auto-Detect menu and make a guess based on the contents of the file given that language assumption. It's enough to read probably first 1024 bytes from file, but I'm loading whole file. Return Encoding.ASCII // Default fallback If( mc.Count = 1 & mc.Groups.Count >= 2 )Įnc = Encoding.GetEncoding( mc.Groups.Value ) Add '.Groups.Value' to the end to test regex MatchCollection mc = Regex.Matches(probe, "^]*encoding[ \\t If (fileContent.Length = 128 ) len = 128 public static Encoding DetectEncoding(byte fileContent)
TEXT ENCODING FIREFOX AUTODRTECT CODE
I needed some basic encoding detection, based on 4 first bytes and probably xml charset detection - so I've took some sample source code from internet and added slightly modified version of Looking for different solution, I found that

TEXT ENCODING FIREFOX AUTODRTECT FULL
Search for view_ (change it to true) and view_ (change it to the path of your text editor make sure it's the full path).You might be interested in making it so a text editor of your choice (one that supports Unicode) will open the page source (or the txt file) instead of Firefox doing it (you can use control+u to open a txt file that is displaying in the current tab, or if it's not a txt file it'll open the webpage's HTML source code, in your favorite text editor). It might be a gargantuan task, but you could always try to edit the Firefox source code to allow for this, and then compile it.

I don't see any extensions that let you do it, either (although I'm sure someone could make one). I don't see a way to change the default encoding in Firefox 54.0 from about:config, but you can manually change it every time you view the page, from the view menu (not ideal, I know).
