Terminal can't render letters/characters that not English (or it can?)?
It's not really that it can't show them, for example: Chinese characters. When I type a Chinese character using ibus, it shows it very well. But when a file have a Chinese name, it can't show this name, it shows blank or long string of numbers with /\"", something like that.
For example, if I open the terminal, change ibus to Chinese and type, I got something like this:
[user@mypc ~]$ 你 好
But if there's a file name 你 好.doc and I use ls command to list it or use ranger to navigate the file, it will show like this:
[user@mypc ~]$ ls
file.txt " .doc"
or sometime like this (I guess it depends on specific characters):
[user@mypc ~]$ ls
file.txt "123/60/4646/"4875/'.doc" (<--I made it up but it kind of look like this)
While I expect to see:
[user@mypc ~]$ ls
file.txt "你 好.doc"
I've already put a Chinese font to /usr/local/share/fonts. I also un-comment zh_cn in locale. Only in terminal it behaves like this. If I use a GUI file manager, it looks fine.
About this post
- Posted
- Archived
- Score
- 0 · 50% up
- Kind
- Text
- ID
- v98acy
8 comments
Are you using a utf8 locale? What does
localeoutput?try doing
LC_ALL=en_US.UTF-8 lsassuming en_US.UTF-8 is generated it with locale-gen. You could use any UTF-8 locale probably.If it fails, try using a different terminal emulator. Also, arch wiki: https://wiki.archlinux.org/title/Locale#Troubleshooting
I try
LC_ALL=en_US.UTF-8 lsand it does work. But mylocale -aoutput already haveen_US.utf8. I don't understand?https://www.ibm.com/docs/en/aix/7.1?topic=locales-understanding-locale-environment-variables
utf-8 which is used in linux is a variable length sequence, it ranges from 1 byte to 4 bytes for a character. You need to set an utf-8 encoding for the locale variables.
If you didn't set LANG, do that first. And then try setting LC_CTYPE
You need to put
and maybe
in one of these files.
Note: The files are source in that order and if the first file is found the next ones will NOT be sourced. So maybe put it somewhere in your ~/.bashrc or ~/.zshrc or ~/.profile and make sure to export the variables.
And LC_ALL should only be used as a last resort because it overrides all the other variables.
which terminal emulators do you use? gnome-terminal works fine for me.
I use konsole
Deleted before we saved it.
No. ls doesn't really operate on individual bytes besides maybe for sorting so the worst you might get is a weirdly sorted list. More importantly ls doesn't need to modify the actual filename and has no reason to display it differently.
A lot of programs don't have to care about the distinction between utf8 and ascii like echo, head and even diff.