java lc ctype,解释导出LANG,LC_CTYPE,LC_ALL的影响

I've just installed Linux Mint 17 and faced a problem that I couldn't use russian language in terminal. (I see ? instead of letters). On one forum I found this solution:

Added in ~/.profile:

export LANG=ru_RU.UTF-8

export LC_CTYPE=ru_RU.UTF-8

export LC_ALL=ru_RU.UTF-8

It helped, but also changed my interface language to Russian (which I didn't want). That's not even a problem, but anyway, I would like to know, how this code works (every line).

Thanks.

解决方案

I'll explain with detail:

export LANG=ru_RU.UTF-8

That is a shell command that will export an environment variable named LANG with the given value ru_RU.UTF-8. That instructs internationalized programs to use the Russian language (ru), variant from Russia (RU), and the UTF-8 encoding for console output.

Generally this single line is enough.

This other one:

export LC_CTYPE=ru_RU.UTF-8

Does a similar thing, but it tells the program not to change the language, but only the CTYPE to Russian. If a program can change a text to uppercase, then it will use the Russian rules to do so, even though the text itself may be in English.

It is worth saying that mixing LANG and LC_CTYPE can give unexpected results, because few people do that, so it is quite untested, unless maybe:

export LANG=ru_RU.UTF-8

export LC_CTYPE=C

That will make the program output in Russian, but the CTYPE standard old C style.

The last line, LC_ALL is a last resort override, that will make the program ignore all the other LC_* variables and use this. I think that you should never write it in a profile line, but use it to run a program in a given language. For example, if you want to write a bug report, and you don't want any kind of localized output, and you don't know which LC_* variables are set:

LC_ALL=C program

About changing the language of all your programs or only the console, that depends on where you put these lines. I put mine in ~/.bashrc so they don't apply to the GUI, only to the bash consoles.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值