Text files do not include character encoding information, so Firefox has no way of knowing which one is correct. Through the menu ViewText 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 guess my first question is why are you using a browser to open plain text files? Or if a browser is needed, why not add a encoding header? Beyond that, what version (locale) of Firefox do you have installed? If I recall en-US version defaults to Unicode but some European country versions default to Western.
    – user3169
    Jun 2, 2017 at 5:43
  • @user3169 I use Firefox to open text files on the local filesystem for printing, because I find that I have easier control over print output than when printing with (for example) a2ps or vi. My Firefox is in English, it might be en-uk though, not sure — how can I tell? Not sure what you mean by adding an encoding header to a plain text file?
    – gerrit
    Jun 2, 2017 at 13:39
  • What is your OS? In Windows 7, you can see it in Program Files\Mozilla Firefox\install.log. Or you can (after backing up your profiles folder to be safe) uninstall the current installation and install with the installer you want (ftp.mozilla.org/pub/firefox/releases). For FF questions you should include FF version and your OS in your question.
    – user3169
    Jun 2, 2017 at 22:52
  • Sometimes in a web page html source you will see something like <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> in the header. If you add such at the top of your text file, FF might select it for you. I am not an html expert but I think you get the idea.
    – user3169
    Jun 2, 2017 at 22:57
  • Possible duplicate here: superuser.com/questions/1062409/… Sep 5, 2017 at 22:58

3 Answers 3


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.

See also similar questions on stackoverflow (with the actual answer (used here)) and unix.stackexchange (with an interesting discussion of some of the rationale).


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,

  1. Open about:config in your URL bar.
  2. 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).
  3. 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.

  • 1
    Well, yes. One of the reasons that I use Firefox to open a text file is because I prefer its printing options over either a2ps or vim, so perhaps my question here is rather an XY problem.
    – gerrit
    Sep 6, 2017 at 9:34

You cannot configure this. If the encoding was a function of user-side configuration, people would create content dependent on their own settings, and then the content would not show up correctly for other readers.

For file: URLs, Firefox autodetects UTF-8 these days.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.