使用 unicode 保存文件时 Emacs 加载字符集映射失败

发布于 2024-12-01 23:54:58 字数 705 浏览 2 评论 0原文

我使用 gnu emacs 23.3.1 在 Windows 7 64 位上创建了一个普通文本文件。我可以使用其他程序(例如 LinqPad)编辑该文件(该文件恰好是 linqpad 脚本,扩展名 .linq)。一切都很好,直到我在文件中放入一个 Unicode 字符,例如希腊字母 λ (lambda)。我可以在 emacs 中输入该字母并且它显示正确。但是,emacs 拒绝保存文件,并报告以下错误

Failure in loading charset map: 8859-7

如果我在 LinqPad 中输入 λ,emacs 将读取并显示它们,但不会保存文件。

我刚刚注意到 Notepad++ 对这个文件还有其他意想不到的行为:它不显示 λ,而是显示成对的奇怪字符,例如 λ。这符合 unicode 字符成对存储的直觉(双关语)。所以看起来这是一种模棱两可的情况(在文本文件中存储 unicode),但看起来 linqPad 和 Visual Studio 也“做了显而易见的事情”。

我想使用 emacs,因为它是我拥有的唯一可以重排注释行序列的程序(// 之后的行,用 Alt-Q 重排它们),并且我想在注释中使用希腊字符,因为我正在描述一个数学程序。

我将不胜感激您的建议和答案。

更新:其他问题中的一些建议说尝试 Mx describe-char,也绑定到 Cx = ;这两个都给了我与上面相同的失败消息,所以它们处于正确的轨道上,只是没有答案。

I created an ordinary text file on Windows 7 64-bit using gnu emacs 23.3.1. I can edit the file with other programs such as LinqPad (the file happens to be a linqpad script, extension .linq). Everything is fine until I put a Unicode character in the file, a character such as the greek letter λ (lambda). I can input the letter in emacs and it displays correctly. However, emacs refuses to save the file, reporting the following error

Failure in loading charset map: 8859-7

If I input the λ in LinqPad, emacs will read and display them, but will not save the file.

I just noticed that Notepad++ has other unexpected behavior with this file: it does not display the λ's, but instead pairs of odd characters such as λ. That is fitting to an untuition (pun intended) that the unicode chars are being stored as pairs. So it looks like this is a kind of ambiguous situation (storing unicode in text files), but it also looks like linqPad and visual studio "do the obvious thing."

I want to use emacs because it's the only program that I have that reflows sequences of commented lines (lines after //, reflows them with Alt-Q), and I want to use greek characters in my comments because I'm describing a mathematical program.

I'll be grateful for advice and answers.

UPDATE: some advice in other questions said to try M-x describe-char, also bound to C-x = ; both of those give me the same failure message as above, so they're on the right track, just not answers.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

≈。彩虹 2024-12-08 23:54:58

当我升级所有软件包(包括 Emacs)时,我就遇到过这种情况,但没有意识到在升级过程中我仍然打开了一个 Emacs 会话。下次我要求它保存一些 Unicode 时,它​​尝试加载 8859-7 并失败,因为升级版本中的路径不同。重新启动 Emacs 后我必须重做编辑。

This once happened to me when I had upgraded all packages (including Emacs) without realising I still had an Emacs session open during the upgrade. Next time I asked it to save some Unicode, it tried to load 8859-7 and failed because the path was different in the upgraded version. I had to redo the edit after restarting Emacs.

昵称有卵用 2024-12-08 23:54:58

我刚刚注意到 Notepad++ 对该文件还有其他意外行为:它不显示 λ,而是显示成对的奇怪字符,例如 λ。< /p>

λ 是使用 ISO-8859-1 编码或 Windows 代码页 1252(西欧)解释字节序列 0xCE、0xBB 时得到的结果。代码页 1252 可能是您计算机上的默认(“ANSI”)代码页。

0xCE、0xBB 是字符 λUTF-8 编码> (U+03BB 希腊小写字母 lambda)。因此,要正确显示它,您需要告诉文本编辑器该文件以 UTF-8 而不是 ANSI 保存。

在 Notepad++ 中,从菜单栏“编码”条目中选择 UTF-8。

在 Emacs 中,Cx Cm c utf-8-dos(或 unix 或其他)作为打开或保存文件的前缀。希望通过保存为 UTF-8,您可以避免 ISO 8859-7(希腊语)地图的任何问题;你当然不想用 8859-7 保存任何文件,或者实际上除了 UTF-8 以外的任何文件,如果你可以的话。

I just noticed that Notepad++ has other unexpected behavior with this file: it does not display the λs, but instead pairs of odd characters such as λ.

λ is what you get when you interpret the byte sequence 0xCE, 0xBB using the encoding ISO-8859-1, or Windows code page 1252 (Western European). Code page 1252 is probably the default (‘ANSI’) code page on your machine.

0xCE, 0xBB is the UTF-8 encoding of the character λ (U+03BB Greek small letter lambda). So to display it correctly you need to tell your text editor that the file is saved in UTF-8 and not ANSI.

In Notepad++, choose UTF-8 from the menu bar ‘Encoding’ entry.

In Emacs, C-x C-m c utf-8-dos (or unix or whatever) as a prefix to opening or saving the file. Hopefully by saving in UTF-8 you'll avoid whatever the problem is with the ISO 8859-7 (Greek) map; you certainly don't want to be saving any files in 8859-7, or indeed anything but UTF-8, if you can help it.

给妤﹃绝世温柔 2024-12-08 23:54:58

我刚刚升级了系统,也遇到了这个问题。我的 Emacs 版本已从 26.1 更新到 27.2。我使用的快速修复(又名 kluge)是以 root 身份 cd 到 /usr/share/emacs 并运行:

% ln -s  27.2  26.1

现在我可以完成编辑会话并在重新启动之前保存所有文件。

I just upgraded my system and hit this problem as well. My Emacs version was updated to 27.2 from 26.1. The quick fix (aka kluge) I used was to cd into /usr/share/emacs as root and run:

% ln -s  27.2  26.1

Now I could finish my editing session and save all my files before rebooting.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文