Why do some Linux utilities output Unicode (when it is not expected)?

While building a tool that reads command output I realized that some Linux utilities output Unicode characters when I didn’t really expect them to do so. For instance, find uses (as opposed to the ASCII ') as a quote character in its error output:

~ > find /root
/root
find: ‘/root’: Permission denied

The same goes for g++:

main.cpp: In function ‘int main()’:
main.cpp:2:9: error: ‘foo’ was not declared in this scope
  return foo;
         ^~~
main.cpp:2:9: note: suggested alternative: ‘bool’
  return foo;
         ^~~
         bool

Is this something to do with my system locale? Or is this something else? Output of localectl:

   System Locale: LANG=en_ZA.UTF-8
                  LANGUAGE=en_ZA:en
       VC Keymap: n/a
      X11 Layout: us
       X11 Model: pc105
Asked By: kobus-v-schoor

||

It has everything to do with your system locale as it describes how utilities should output locale specific symbols and their combinations, e.g. ‘’ instead of "".

If you don’t want this, use a different locale, e.g. C which is as standard and pristine as possible:

$ LC_CTYPE=C find /root
/root
find: '/root': Permission denied
Answered By: Artem S. Tashkinov
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.