bash 如何将 LANG 设置为 ascii?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27044/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I set LANG to ascii?
提问by Orion Edwards
I'm accessing an Ubuntu machine using PuTTY, and using gcc.
我正在使用 PuTTY 和 gcc 访问 Ubuntu 机器。
The default LANGenvironment variable on this machine is set to en_NZ.UTF-8, which causes GCC to think PuTTY is capable of displaying UTF-8 text, which it doesn't seem to be.
Maybe it's my font, I don't know - it does this:
LANG这台机器上的默认环境变量设置为en_NZ.UTF-8,这导致 GCC 认为 PuTTY 能够显示 UTF-8 文本,但它似乎并非如此。也许这是我的字体,我不知道 - 它是这样的:
foo.c:1: error: expected a=a, a,a, a;a, aasma or a__attribute__a at end of input
If I set it with export LANG=en_NZ, then this causes GCC to behave correctly, I get:
如果我用 设置它export LANG=en_NZ,那么这会导致 GCC 行为正确,我得到:
foo.c:1: error: expected '=', ',', ';', 'asm' or '__attribute__' at end of input
but this then causes everything else to go wrong. For example
但这会导致其他一切都出错。例如
man foo
man: can't set the locale; make sure $LC_* and $LANG are correct
I've trawled Google and I can't for the life of me find out what I have to put in there for it to just use ASCII. en_NZ.ASCIIdoesn't work, nor do any of the other things I can find.
我已经搜索了谷歌,但我终其一生都无法找出我必须在那里放入什么才能仅使用 ASCII。en_NZ.ASCII不起作用,我能找到的任何其他东西也不起作用。
Thanks
谢谢
回答by Chris Jester-Young
LANG=en_NZis correct. However, you must make locale files for en_NZ.
LANG=en_NZ是正确的。但是,您必须为en_NZ.
For Ubuntu, edit /var/lib/locales/supported.d/localand add en_NZ ISO-8859-1to the file. If your system is another distribution (including Debian), the location will be different. Look at /usr/sbin/locale-genand see where it stores this info.
对于 Ubuntu,编辑/var/lib/locales/supported.d/local并添加en_NZ ISO-8859-1到文件中。如果您的系统是另一个发行版(包括 Debian),则位置会有所不同。查看/usr/sbin/locale-gen并查看它存储此信息的位置。
Afterwards, run locale-gento create the en_NZlocale file. Hope this helps!
然后,运行locale-gen以创建en_NZ语言环境文件。希望这可以帮助!
回答by Cebjyre
Putty can display utf - I think it is in appearance -> translation (or something, I don't have access to it right now).
Putty 可以显示 utf - 我认为它是外观 -> 翻译(或其他东西,我现在无法访问它)。
回答by drewr
For Debian 5.0 Lenny:
对于 Debian 5.0 Lenny:
aptitude install locales
If that's already installed:
如果已经安装:
dpkg-reconfigure locales

