简体   繁体   English

emacs中的汉字-Windows上的无窗口系统

[英]Chinese characters in emacs --no-window-system on windows

I recently started using emacs on Android in Termux. 我最近开始在Termux的Android上使用emacs。 My projects feature some chinese characters, which are displayed there just fine. 我的项目中包含一些汉字,这些汉字显示得很好。

Termux的Emacs

When later opening the same file in Emacs on Windows, I was disappointed to see them displayed as \\xxxx 稍后在Windows的Emacs中打开相同文件时,我很失望地看到它们显示为\\xxxx

Windows上的Emacs

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 emacs术语模式中的Unicode字符

but it did no help me solve the issue. 但这并没有帮助我解决问题。

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 . 在Termux中,它表示UUU ,但是在Windows中,它表示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. U代表UTF-8,而D代表各种DOS代码页。 (You can find this using Mx list-coding-systems . This is all described in the Mode Line section of the Emacs manual .) (您可以使用Mx list-coding-systems找到它。这全部在Emacs手册的Mode Line部分中进行了描述。)

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. 因此,这意味着Emacs可以正确读取文件,但是它认为终端无法显示中文字符,因此它使用\\uxxxx表示法作为后备。 I'm not sure how to get this to work properly in a Windows terminal, but try Mx set-terminal-coding-system with utf-8 - it might just work. 我不确定如何使它在Windows终端中正常工作,但是尝试将Mx set-terminal-coding-systemutf-8 -可能就可以了。


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. 顺便说一句,如果您将Emacs作为“正常” Windows应用程序而不是在终端上运行,则字符应会自动正确显示,因此,如果存在阻止您执行此操作的特定问题,则可能值得尝试修复该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM