Closed GoogleCodeExporter closed 9 years ago
additional information about the pictures:
the file cygwin.wsf is encoded in UTF-8.
the first two lines of netstat's output is chinese (GBK I guess).
Original comment by sharkke.w@gmail.com
on 18 Jan 2011 at 12:32
Netstat is a Windows program, so it doesn't care about Cygwin locales. You
could try switching the Windows console codepage to UTF-8 using the following
command though:
cmd /c chcp 65001
Another thing you could try is iconv, e.g. to convert from GBK to the current
locale:
netstat | iconv -f GBK
Finally, there already is a control sequence for changing mintty's locale from
the command line. See http://code.google.com/p/mintty/wiki/CtrlSeqs#Locale. You
can use it with a command like this:
echo -ne '\e]701;C.GBK\a'
Original comment by andy.koppe
on 25 Jan 2011 at 5:47
@ andy.koppe
Thank you a lot, it solves my problem.
Original comment by sharkke.w@gmail.com
on 27 Jan 2011 at 7:56
You're welcome. Which suggestion did the trick?
Original comment by andy.koppe
on 28 Jan 2011 at 8:27
The three methods all work, but with a little difference:
"cmd /c chcp 65001" make programs like "netstat" generates English output.
Spelling error with "netstat | iconv -f GBK", "netstat | iconv -f GBK -t UTF-8"
will work in C.UTF-8 environment, but it will wait untill all output has been
generated.
"echo -ne '\e]701;C.GBK\a'" does what I wanted.
and I write a small script to avoid the long command line:
<code lang="python">
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import os, sys
if len(sys.argv) > 1:
if sys.argv[1] in ['936', '65001']:
os.system('cmd /c chcp %s' % sys.argv[1])
exit()
elif sys.argv[1] in ['C.GBK', 'C.UTF-8']:
os.system('echo -ne \'\e]701;%s\a\'' % sys.argv[1])
exit()
print("Pig head, wrong argument, check it!")
</code>
Original comment by sharkke.w@gmail.com
on 28 Jan 2011 at 12:39
Original issue reported on code.google.com by
sharkke.w@gmail.com
on 18 Jan 2011 at 12:29Attachments: