1

I've got a problem with Cyrillic alphabet. My terminal will display Cyrillic normally as well most of my programs the only exception I've found so far is ls. Instead of normal Cyrillic it displays ?????? ???.

I am Running macOS Mojave.

Screenshots included.

terminal finder

  • If you unset all the LC_* variables does it start working? (Try unset $(set | sed -n '/^LC_/s/=.*//p') and then ls). If so, it's a locale issue. – roaima Mar 6 at 21:19
  • It was indeed problem with locale. I've had LANG set to en, unsetting LANG and LC_ALL fixed the issue. Thanks for the suggestion! – Victor Mar 7 at 11:48
1

You need to set the locale to one that can handle UTF-8 characters. The C locale cannot (will not) do so.

One option is to remove the LC_* environment variables that are forcing the locale to be C, but it would be better to address the underlying issue and set them correctly in the first place.

unset $(set | sed -n '/^LC_/s/=.*//p')
1
export LC_ALL=ru_RU.UTF-8

Explanation: First, make sure you have the correct locale installed :

locale -a | egrep -i 'ru.*utf'
ru_RU.UTF-8

Then you can try to set your correct locale. My first try would be:

export LC_ALL=ru_RU.UTF-8

And you can make a simple test:

( date; export LC_ALL=ru_RU.UTF-8 ; date +%c)
Fri Mar  8 08:08:50 -03 2019
пятница,  8 марта 2019 г. 08:08:50

Then you can make a slightly(?) more complex test:

( date; \
    export LC_ALL=ru_RU.UTF-8 ; \
    d=$(date +%c | sed 's/ /_/g'); \
    mkdir /tmp/test; \
    echo $d > /tmp/test/$d.txt; \
    echo "with right locale:"; \
    ls -ltra /tmp/test ; \
    echo "with 'C' locale:"; \
    LC_ALL=C ls -ltra /tmp/test )
Fri Mar  8 08:14:19 -03 2019
with desired locale:
total 12
-rw-r--r--  1 vfalcao wheel  48 мар  8 08:13 пятница,__8_марта_2019_г._08:13:21.txt
-rw-r--r--  1 vfalcao wheel  48 мар  8 08:13 пятница,__8_марта_2019_г._08:13:38.txt
drwxrwxrwt 19 root    wheel 608 мар  8 08:13 ..
drwxr-xr-x  5 vfalcao wheel 160 мар  8 08:14 .
-rw-r--r--  1 vfalcao wheel  48 мар  8 08:14 пятница,__8_марта_2019_г._08:14:19.txt
with 'C' locale:
total 12
-rw-r--r--  1 vfalcao wheel  48 Mar  8 08:13 ??????????????,__8_??????????_2019_??._08:13:21.txt
-rw-r--r--  1 vfalcao wheel  48 Mar  8 08:13 ??????????????,__8_??????????_2019_??._08:13:38.txt
drwxrwxrwt 19 root    wheel 608 Mar  8 08:13 ..
drwxr-xr-x  5 vfalcao wheel 160 Mar  8 08:14 .
-rw-r--r--  1 vfalcao wheel  48 Mar  8 08:14 ??????????????,__8_??????????_2019_??._08:14:19.txt
  • 1
    I'm not entirely sure, but I think that locale names are case dependent, so ru_RU.UTF-8 rather than ru_RU.utf-8 (this doesn't seem to matter on macOS though). – Kusalananda Mar 8 at 11:22
  • Well, my example was made in a Mac. It worked with lowercase utf-8. Just to be sure, I'll uppercase it. – vfalcao Mar 8 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.