Benj
Benj

Reputation: 989

Chinese characters in emacs --no-window-system on windows

I recently started using emacs on Android in Termux. My projects feature some chinese characters, which are displayed there just fine.

Emacs in Termux

When later opening the same file in Emacs on Windows, I was disappointed to see them displayed as \xxxx

Emacs on Windows

I am not sure how to search for a solution, because I do not what the problem is.

The only thing I found related to my problem is this:

Unicode characters in emacs term-mode

but it did no help me solve the issue.

Upvotes: 0

Views: 390

Answers (1)

legoscia
legoscia

Reputation: 41548

You can tell what's going on by looking at the first few characters in the mode line. In Termux, it says UUU, but in Windows it says DDU. These three characters stand for:

  1. the coding system for keyboard input
  2. the coding system for terminal output
  3. the coding system of the file in the buffer

U stands for UTF-8, while D stands for various DOS code pages. (You can find this using M-x list-coding-systems. This is all described in the Mode Line section of the Emacs manual.)

So this means that Emacs is reading the file correctly, but it thinks that the terminal is unable to display the Chinese characters, so it uses the \uxxxx notation as a fallback. I'm not sure how to get this to work properly in a Windows terminal, but try M-x set-terminal-coding-system with utf-8 - it might just work.


As an aside, if you run Emacs as a "normal" Windows application instead of in a terminal, the characters should display correctly automatically, so if there is a particular problem preventing you from doing so, it might be worth trying to fix that instead.

Upvotes: 1

Related Questions