Text files do not include character encoding information, so Firefox has no way of knowing which one is correct. Through the menu View → Text encoding I can select the appropriate encoding. I find myself doing this every time I open a text file, as it appears to be always set to Western by default, but my text files are always Unicode (UTF-8). Is there any way to set the default encoding to Unicode rather than Western?
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). I don't see any extensions that let you do it, either (although I'm sure someone could make one). 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.
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). To do that,
about:configin your URL bar.
- Search for
view_source.editor.external(change it to true) and
view_source.editor.path(change it to the path of your text editor; make sure it's the full path).
- Restart your browser.
Then it'll launch a temporary file with the text of the page source in your text editor (which for a text file is the actual text file). I tested it and it works.
The glaring problem with this is it won't let you click to open scripts referenced in the source code if you're viewing HTML source code (if you have a habit of clicking links to script files).
It appears that another version of Firefox had the ability to set the default encoding once upon a time, but that doesn't exist in 54.0 on Xubuntu.
If changing the default encoding for all offline files (not only text files) would also work for you, then there is now (I'm not sure since when, but it works in Firefox 59.0) an option to change the default encoding to UTF-8 in
about:config: set the value of
intl.charset.fallback.utf8_for_file to true.
Aside: it appears that one of the purposes of preventing the setting of the default encoding for online files is to avoid fingerprinting.