command line argument parsing get extra ^X for Chinese characters when started from native win app

Xuefer xuefer@gmail.com
Tue Dec 24 07:37:00 GMT 2013


tested with
$ uname -a
CYGWIN_NT-6.1 mOo-PC 1.7.27(0.271/5/3) 2013-12-09 11:54 x86_64 Cygwin

run the following code in .bat file, the file should be in GBK
encoding. as your system should be GBK encoding by default to parse
the batch file correctly
or copy paste the code to start->run
==[ to get actual wrong output ]
c:\app\cygwin\bin\env LANG=zh_CN.UTF-8 PATH=/usr/bin bash -c "echo 中文;
echo 中文 > a.txt; cat a.txt; xxd a.txt; echo please vim a.txt; sh"
===============

==[  actual output ]
 中 文
 中 文
0000000: 18e4 b8ad 18e6 9687 0a                   .........
please vim a.txt
sh-4.1$
===============
now when you do "vim a.txt", you see
a.txt
^X中^X文

copy and paste the code to mintty. with mintty encoding set to UTF-8
==[ code to get correct expected output ]
echo 中文; echo 中文 > a.txt; cat a.txt; xxd a.txt; echo please vim a.txt
===============

==[  expected output ]
中文
中文
0000000: e4b8 ade6 9687 0a                        .......
please vim a.txt
===============
now when you do "vim a.txt", you see
a.txt
中文






a.bat is provided as attachment in text, not sure if accepted by this
mailing list system.
-------------- next part --------------
c:\app\cygwin\bin\env LANG=zh_CN.UTF-8 PATH=/usr/bin bash -c "echo ����; echo ���� > a.txt; cat a.txt; xxd a.txt; echo please vim a.txt; sh"
-------------- next part --------------
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


More information about the Cygwin mailing list