If you have a pretty recent Linux system like I have, you most likely have had the pleasure or the following message when starting mcedit:
Chosen display charset or source codeset does not match one set via locale.
You can then “Fix” it or “Skip” and choose to remember it. For me, fixing or skipping the dialog does not seem to do anything but that is most likely because I don’t use the charset completely (no ‘weird’ characters in my text files). Even worse, if you find it to do something — chances are you want to use the Fix option — and tick “Do not ask again”, the next time the file is broken again! This is because the tick box does not respect your choice but rather takes it as “Skip any problem detection in the future”…
Annoying as it may be, the real cause is the fact that you are most likely not using the correct character encoding on your system by default. Chances are, when you update your system you get this annoying “Generating code page” message a million times over. If so, you just generated support to view every text encoding known to man — good for you!
I on the other hand, will only view UTF-8 files and I’m not really interested in anything else. So I decided to reduce codepage support to 2 languages: Dutch and English. Note that the Dutch support in this case tends to translate messages in programs (ugh) but it also adds support for the Euro sign: ‘€’
/etc/locale.gen and add the following lines:
1 2 3 4 5
en_GB ISO-8859-1 en_GB.UTF-8 UTF-8 nl_NL UTF-8 nl_NL@euro UTF-8 nl_NL.utf8 UTF-8
I cheated a bit by replacing the default ISO-8859-1 or ISO-8859-15 character mapping for Dutch with the UTF-8 one. It seems this choice is allowed and gives me proper UTF-8 support with the nl_NL locale.
Save the file and run
cyberxps ~ # locale-gen * Generating 5 locales (this might take a while) with 1 jobs * (1/5) Generating en_GB.ISO-8859-1... [ ok ] * (2/5) Generating en_GB.UTF-8... [ ok ] * (3/5) Generating nl_NL.UTF-8... [ ok ] * (4/5) Generating nl_NL.UTF-8@euro... [ ok ] * (5/5) Generating nl_NL.UTF-8... [ ok ] * Generation complete
Looks familiar? Yes that is the dreaded locale generation but this time it only created the locales we will use meaning it completes in a second instead of 10 minutes… Run
locale -a to make sure you got what you wanted:
cyberxps ~ # locale -a C en_GB en_GB.iso88591 en_GB.utf8 nl_NL nl_NL@euro nl_NL.utf8 nl_NL.utf8@euro POSIX
Now open up
/etc/env.d/02locale and put the locale selection in and reload afterwards:
cyberxps ~ # echo 'LANG="nl_NL.utf8@euro"' >> /etc/env.d/02locale cyberxps ~ # env-update >> source /etc/profile >>> Regenerating /etc/ld.so.cache... cyberxps ~ # export | grep LANG declare -x LANG="nl_NL.utf8@euro"
All done, we switched to the new locale and mcedit can stop complaining now. As an added bonus each file you edit will be created in UTF-8.