purcell / emacs.d

An Emacs configuration bundle with batteries included
BSD 2-Clause "Simplified" License
6.82k stars 2.04k forks source link

UTF-8 support when running 'emacs -nw' in terminal #858

Closed pokho closed 6 months ago

pokho commented 6 months ago

Warning: I havent run any regression tests on the change, so I dont know if it causes other issues.

Verified on: GNU Emacs 27.1, Kubuntu 22.04.3 LTS, Konsole 21.12.3

purcell commented 6 months ago

There's already UTF support, ie. I'm not aware of any specific issue that this change addresses: can you say more?

I used to set various coding system variables explicitly like this, but several years ago removed them because they messed up folks using Chinese and other non-UTF8 multi-byte charsets. But since removing them, nobody has reported problems.

pokho commented 6 months ago

Sorry, I forgot to describe the issue before submitting a fix :) Here's a screenshot of how it looks on my system. Unicode characters are not displayed, so for instance the heart character written in the *scratch* buffer on launch, is rendered as \u2665 instead.

Screenshot_20240112_104353

After applying this fix (which I found from https://emacs.stackexchange.com/questions/51387/howto-display-unicode-character-u2026-in-terminal-mode-in-emacs), unicode characters seem to be rendered correctly.

Screenshot_20240112_104617

purcell commented 6 months ago

I'd suspect that your locale isn't configured right, because Emacs should detect and support UTF-8 locales automatically. What's the LC_CTYPE environment variable in your terminal? Perhaps export LC_CTYPE="en_US.UTF-8" fixes it.

purcell commented 6 months ago

Yeah, I can reproduce this locally if I unset LC_CTYPE, so just set that. The locale command will display the status of your various locale-related env vars.

pokho commented 6 months ago

Ah, you are right thank you. My locale was set to LC_CTYPE="en_NG" causing the issue. Setting locale to LC_CTYPE="en_US.UTF-8" fixes it :)

I'll close this pull request again

purcell commented 6 months ago

Great, glad you got it working!