reddit / emacs

Emacs 28.0.92 in Windows terminal unicode display problems

JohnDoe365 · 2022-04-01 19:12
Hello, I am using GNU Emacs 28.0.92 (build 2, x86\_64-w64-mingw32) of 2022-03-27 on Windows 10. The problem is that many (not all!!) unicode-characters in e.b. text are not printed "as they are" but instead "encoded". Certain unicodes have no issue like Umlauts, eg. ö ä ü or ß are all displayed correctly and are properly "uni-"encoded using two bytes. Problem can be seen here: ​ https://preview.redd.it/ah42nzguuyq81.png?width=492&format=png&auto=webp&s=a4130f7b7b3ae9bec3f6bdc324c7b3c0e2fa8418 and with many other unicode characters. File encoding info is: U -- utf-8-dos (alias: mule-utf-8-dos cp65001-dos) UTF-8 (no signature (BOM)) Type: utf-8 (UTF-8: Emacs internal multibyte form) EOL type: CRLF This coding system encodes the following charsets: unicode The file is recognized as having unicode-encoding and saves properly preserving unicode. ​ ​ It is not a font issue, if I cat or more the file in terminal using the same font, the unicode characters get properly displayed. It is not an issue of Windows terminal, if I start emacs -nw from cmd.exe, powershell or Git Bash it's all the same (not from within Windows terminal) Note, when I open the same file using the same .emacs configuration in Gui-Mode all Unicode characters display correctly. **Edit 2022-04-14** After some more investigation: * setting the console codepage with [chcp.com](https://chcp.com) 65001 displays now all unicode characters in a regular editing window. A recursive grep output with path names containing eg. umlauts still gets them wrong (using the same grep on git bash without altering the codepage displays them correctly) * BUT now there are display issues, the last character on a line is not displayed, sometimes charcters "remain" where they are when scrolling, sometimes after a unicode character there are spurious spaces ​
eli-zaretskii · 2022-04-02 07:00
Emacs uses the current console codepage to judge whether a character can or cannot be displayed by the Windows terminal. You could try using `w32-set-console-output-codepage` to change Emacs's notion of the codepage to use. However, in general, displaying Unicode characters from a console program on MS-Windows is tricky at best (read: doesn't really work). First, writing to the console of characters outside the current codepage works only on the latest Windows versions, and even there not 100%; the MS documentation keeps silent about how to do that. Next, there's no way of knowing what font is used by the terminal, and therefore no way of knowing what Unicode characters are supported by that font, even if the console codepage does support those characters. So Emacs plays it safe and displays the character's codepoint if it isn't sure the character can be displayed. May I ask why you are interested in `-nw` sessions on MS-Windows? they don't present any advantages on MS-Windows, only disadvantages. Use GUI sessions, and you will be free of all this mess.
JohnDoe365 · 2022-04-14 05:26
> May I ask why you are interested in -nw sessions on MS-Windows? they don't present any advantages on MS-Windows, only disadvantages. Use GUI sessions, and you will be free of all this mess. Using mostly Linux cli tools I prefer the -nw Session it over the gui version. On Linux -nw works without issues.