Solutions for Chinese Input and Output in cygwin-general Linux technology-Linux programming and kernel information. The following is a detailed description. I thought about many ways to run files under one of my directories, but I couldn't do anything. All the paths are finally locked. How can I enter my Chinese directory name under cygwin? After trying a lot of online methods, it was impossible to make a trip. Later, with the help of experts, I finally lost my way back. The road was really tortuous and the future was bright.
In fact, the reason why cygwin cannot enter Chinese characters is that the highest bit of Chinese characters is 1, so it is processed as a controller. OK. Now let's take a look at how it works, and then let's see why it works.
How to do this: If your user directory (/home/XXX) has :. inputrc ,. bashrc /. bash-profile: two or three files. Congratulations, you don't have to create them. You only need to modify them. If not, create these three files. In Linux, We have a variety of file creation methods, but if you do not have a vi editor in cygwin, you can create these three files as follows:
(1) copy the three files from/ect/skel to your main directory.
(2) Use notepadto create these three files. However, it is important that you save them as a. txt file in ansi.pdf. Remember this.
OK, the file is now created, so how to modify the file is left: (write in ANSI encoding format)
(1) Add the following in the. inputrc file:
Set meta-flag on
Set convert-meta off
Set output-meta on
Set input-meta on
Set completion-ignore-case on
(2) Add the following in the. bashrc or. bash-profile file:
Alias ls = 'ls -- show-control-chars -- color = auto'
Export LESSCHARSET = latin1
Save the modification as an ANSI encoded format.
OK.
Now let's take a look at the reason why cygwin cannot enter Chinese characters because the highest bit of Chinese characters is 1, so it is processed as a controller, meta-flag, for more information about convert-meta and other options, see man bash. To put it simply, set meta-flag on to allow Chinese characters to be input from the terminal. Otherwise, the highest bit of each byte is filtered out. convert-meta off is used to disable conversion of Chinese characters into escape sequences, because Chinese characters are expressed in two bytes, the highest bit of the first byte starts with 1 and can be equivalent to an escape character. output-meta on allows direct output of Chinese characters to the terminal; input-meta on is to allow direct input of Chinese characters to the terminal; set completion-ignore-case on can be pressed during echo Then you can use readlineto generate abc.txt ;? The same applies to show-control-chars.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.