diff options
author | jaseg <git@jaseg.net> | 2018-12-02 13:34:14 +0900 |
---|---|---|
committer | jaseg <git@jaseg.net> | 2018-12-02 13:37:31 +0900 |
commit | da9174ed19868c06299d9363db232d6a9eca31ae (patch) | |
tree | e4dd05d1acf245b3c40e75696f4406999d7c64ec | |
parent | 27768b78a4e6db74ae9f0b57581504adc25f2c82 (diff) | |
download | lolcat-da9174ed19868c06299d9363db232d6a9eca31ae.tar.gz lolcat-da9174ed19868c06299d9363db232d6a9eca31ae.tar.bz2 lolcat-da9174ed19868c06299d9363db232d6a9eca31ae.zip |
Force encoding to utf8 by default, allow override via -l switch
-rw-r--r-- | lolcat.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -36,6 +36,7 @@ static char helpstr[] = "\n" " -h <d>: Horizontal rainbow frequency (default: 0.23)\n" " -v <d>: Vertical rainbow frequency (default: 0.1)\n" " -f: Force color even when stdout is not a tty\n" + " -l: Use encoding from system locale instead of assuming UTF-8\n" " --version: Print version and exit\n" " --help: Show this message\n" "\n" @@ -81,6 +82,7 @@ int main(int argc, char** argv) int cc = -1, i, l = 0; wint_t c; int colors = isatty(STDOUT_FILENO); + int force_locale = 1; double freq_h = 0.23, freq_v = 0.1; struct timeval tv; @@ -107,6 +109,8 @@ int main(int argc, char** argv) } } else if (!strcmp(argv[i], "-f")) { colors = 1; + } else if (!strcmp(argv[i], "-l")) { + force_locale = 0; } else if (!strcmp(argv[i], "--version")) { version(); } else { @@ -123,7 +127,10 @@ int main(int argc, char** argv) inputs_end = inputs + 1; } - setlocale(LC_ALL, ""); + if (force_locale) + setlocale(LC_ALL, "C.UTF-8"); + else + setlocale(LC_ALL, ""); i = 0; for (char** filename = inputs; filename < inputs_end; filename++) { |