cygwin中文乱码

8:29:00 PM 0 Comments

msys中文显示


注意:中文注释可以保留,但文件必须采用linux文件格式,即用\n作换行符。可以用notepad++, vim等工具创建

.bash_profile

# 让ls和dir命令显示中文和颜色
alias ls='ls --show-control-chars --color'
alias dir='dir -N --color'
alias less='less -r'
# 设置为中文环境,使提示成为中文
export LANG="zh_CN.GBK"
# 输出为中文编码
export OUTPUT_CHARSET="GBK"

.inputrc

# 关闭bash命令行8字节字符转义符的转换
set convert-meta off

# 使bash命令行支持8字节字符输入
set input-meta on

# 使bash命令行支持8字节字符输出
set output-meta on

set meta-flag on

set completion-ignore-case on


Why don't international (Unicode) characters work?

Internationalization is a complex issue. The short answer is that Cygwin is not Unicode-aware, so things that might work in Linux will not necessarily work on Cygwin. However, some things do work. To type international characters (£äö) in bash, add the following lines to your ~/.inputrc file and restart bash:

set meta-flag on
set convert-meta off
set output-meta on
set input-meta on
set kanji-code sjis

These are options to the readline library, which you can read about in the bash(1) and readline(3) man pages. Other tools that do not use readline for display, such as less and ls, require additional settings, which could be put in your ~/.bashrc:

alias less='/bin/less -r'
alias ls='/bin/ls -F --color=tty --show-control-chars'
export LANG="ja_JP.SJIS"
export OUTPUT_CHARSET="sjis"

These examples use the Japanese Shift-JIS character set, obviously you will want to change them for your own locale.




Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard.