A colleague was using Qt's built-in QTextStream class to rewrite the /etc/network/interfaces file on an Ubuntu system. Part of that code included a call to QTextStream's setCodec() method, where the codec was set to UTF-8. (see https://doc.qt.io/qt-5/qtextstream.html#setCodec if you're curious)

This got me wondering about what the Linux configuration files are SUPPOSED to be written as. It seems like ISO 8859-1 would be the closest to what I'd consider "plain ASCII" style of text, and I would (perhaps naively) assume this to be correct since most configurations files are plain English with no need for much more than the basic alphabet, numbers and a few punctuation signs.

But then I also wonder what would someone from a non-English speaking country do if they wanted to put comments into such files using other characters that aren't in ISO-8859-. Are they just plain "out of luck" ?

There are obviously a lot of "standard" configuration files that you'd find on an Ubuntu/Linux system, e.g.

  • /etc/network/interfaces
  • /etc/ntp.conf
  • /etc/hostname
  • ...

Would anyone care to weigh in on what encoding is actually supported/expected in these sort of files ? And where this is actually documented ? Is it enshrined in some sort of "Linux developers manifesto" as something writers of new Linux system services should be following, and if so, where would I find a definitive source of that information ?

  • UTF-8 is as close to plain ASCII as is ISO-8859-1, in that both contain ASCII as a subset. Both encodings produce identical results if you restrict the text to plain ASCII. ISO-8859-1 has the problem, as you point out yourself, that ISO-8859-1 is a much more restricted encoding. IMHO, the 8-bit ISO-8859 encodings are a thing of the past and should be phased out. Commented Apr 11, 2019 at 14:05
  • If a particular service, for example the NTP daemon, is only written with ASCII in mind when it reads /etc/ntp.conf, what is going to happen if someone embeds UTF-8 non-ASCII characters (e.g. in a comment). Is it explicitly doing UTF-8 aware processing of the configuration file (by design), or is it just "dumb luck" that it works ? That's what I'm trying to understand here. Obviously there are a lot of "moving pieces" so I can't just read all their source code to figure this out. That's why I was looking for some sort of "recipe" document that they are all following (hopefully !)
    – JasonA
    Commented Apr 11, 2019 at 16:46
  • If the program that reads the configuration file expects plain ASCII, then I would say the chance it chokes on ISO-8859 is just as big as it is with UTF-8. If the non-ASCII characters are in comments, the chance is probably quite small. Commented Apr 11, 2019 at 17:49

1 Answer 1


The general Encoding can be set via the LANG environment variable, but by now nearly all Linux distros and tools have migrated to UTF-8. The main advantage for configuration files is, that any string using only ASCII characters are valid ASCII. So for most configuration files it doesn't really matter, since they only use those characters anyway

  • Does UTF-8 BOM matter on Linux system files?
    – Martin
    Commented Dec 31, 2019 at 16:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .