【问题标题】:Shell in emacs displays names of variables by preceding them \200\230Emacs 中的 Shell 通过在变量前面 \200\230 来显示变量的名称
【发布时间】:2012-04-29 17:21:49
【问题描述】:

当我在 emacs 中从 shell/eshell/term 运行编译指令时,变量的名称在 shell 中显得很奇怪。

这是一个示例代码(有一些随机错误)和我编译时的输出:

#include iostream
#include cstdlib


int main (void)
{
cscdsd ;//some random error 
return ;
}
//shell o/p:
g++ new.cc 
new.cc: In function â\200\230int main()â\200\231:
new.cc:7: error: â\200\230cscdsdâ\200\231 was not declared in this scope
new.cc:8: error: return-statement with no value, in function returning â\200\230intâ\200\231
~/codes $ 

我发现 \200\230 和 \200\231 表示变量或函数名的开始和结束。 有什么想法会发生什么或如何摆脱它?

【问题讨论】:

    标签: shell emacs


    【解决方案1】:

    \200 是一个八进制转义序列。在十六进制中,â\200\230E2 80 98,这就是 U+2018(左单引号)在 UTF-8 中的编码方式。同样,â\200\231 是 U+2019(右单引号)。这就是g++ 发出 UTF-8 而 Emacs 将其解释为 ISO-8859-1 时发生的情况。

    您可能需要将default-process-coding-system 设置为不同的值。尝试(在你的 ~/.emacs 中):

    (setq default-process-coding-system '(utf-8-unix . utf-8-unix))
    

    还有其他方法可以告诉 Emacs 期望什么样的编码系统。阅读变量default-process-coding-system & process-coding-system-alist 和函数universal-coding-system-argument & set-buffer-process-coding-system 的文档。

    【讨论】:

      【解决方案2】:

      文本编码应该是LANG 环境变量的一部分。
      export LANG=en_US.UTF-8 应该修复。
      在 Ubuntu 系统上,将其更改为 /etc/default/locale

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-06-02
        相关资源
        最近更新 更多