当我从 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 表示变量或函数名的开始和结束。 有什么想法会发生什么或如何摆脱它?
最佳答案
\200
是一个八进制转义序列。以十六进制表示,â\200\230
是 E2 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
.
关于emacs中的Shell通过在它们前面显示变量的名称\200\230,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10374200/