Recently, I’ve discovered that some of the programs that I’ve written and some of their dependencies make a bad assumption. They assume that the system uses UTF-8 by default. That assumption is especially bad because Windows uses UTF-16.
As part of the debugging process, I tried to run my software with the encoding set to plain-old ASCII. Doing that was harder than I expected. Here’s what I had to do to. These’s instructions are specific to Arch Linux. I don’t know how well they’ll work on other distros.
- Find out what name
localeuses for ASCII.
/usr/share/i18n/charmapsshould contain a file for each character encoding that your system supports. On my system, the encoding wasn’t called “ASCII”. Instead it was called “ANSI_X3.4-1968”. IANA’s character set list might be helpful here. It has a list of aliases for “US-ASCII”.
Generate a locale for that character set:
Add the following on a new line:
language[_country].charset” will be the name of the new locale.
countryshould be a valid two letter language code and a valid two letter country code respectively.
charsetshould be the name of the character set you found before. For mine, I did:
In that example, the locale is named “
- Make sure that Konsole is installed
LANG='locale' konsole -p DefaultEncoding='charset'.
On my system, the final command was:
LANG='en_US.ANSI_X3.4-1968' konsole -p DefaultEncoding='ANSI_X3.4-1968'