The screen shot (rather than a copy/paste) was very useful. The good
news is that I know what you want/are trying to do.
You want to use the Microsoft CMD window to run console Jython scripts
with a Chinese locale (cp936, see
and http://en.wikipedia.org/wiki/Code_page_936 ).
The bad news is that it is not possible. The Microsoft CMD does NOT
support UTF8, you simply can't use utf8 reliably in a CMD window. You
really want cp936 support (to match the desktop locale settings) but
Jython does NOT support CJK either (http://www.jython.org/faq3.html
claims it would but it was not implemented, see
http://bugs.jython.org/issue1066 for more info, the good news is that a
future release should have something).
I did knock up an NIO based codec (very simply it worked fine for
Japanese, it would take 2 mins to make a cp936 one), there was no
interest at the time, see
The options as I see it are:
* set the encoding to cp936 (which is what your desktop is using), and
create a cp936 codec (based on my nio encoding experiment or some
other mechanism, see last two options)
* use jythonconsole (it looks cool, I've not had chance to play with
it yet) with utf8, http://code.google.com/p/jythonconsole/
* use mintty, I've had mixed success (things work but CTRL-C behavior
is odd) using this with utf8 applications under windows but I've not
tried jython/java apps http://code.google.com/p/mintty/
* pay someone to add CJK support to the version of Jython you are using
* add CJK support yourself to the version of Jython you are using
On 1/31/2012 2:48 AM, Sheng Qiang Xu wrote:
> Thanks for your reply.
> I tried to force the encoding, but not work yet.
> Here is what I tried. My OS Locale is Chinese. Before I forced the
> encoding value, it is already utf-8.
> Best Regards
> Inactive hide details for Philip Jenvey ---2012-01-31 11:47:30---On
> Jan 17, 2012, at 7:17 PM, Sheng Qiang Xu wrote:Philip Jenvey
> ---2012-01-31 11:47:30---On Jan 17, 2012, at 7:17 PM, Sheng Qiang Xu
> *Philip Jenvey <pjenvey@...>*
> 2012-01-31 11:47
> Sheng Qiang Xu/China/IBM@...
> jython-users users <jython-users@...>
> Re: [Jython-users] I can only input a character with
> java.lang.System.console().readline() in Chinese or Japanese language
> On Jan 17, 2012, at 7:17 PM, Sheng Qiang Xu wrote:
> > I'm using jython 2.5.1 and my OS is windows XP and language is Chinese.
> > When using java.lang.System.console().readline() to input text, I
> can only input a character (the behavior seems like pressing enter)
> and the console jumps to next line.
> > Could somebody pls help to take a look at this?
> > Thanks.
> You probably have an incorrect input encoding value set on your platform.
> You can see what Jython uses for its input encoding by looking at the
> value of sys.stdin.encoding. You can try forcing it to say UTF-8 by
> passing "-Dpython.console.encoding=UTF-8" to Jython
> Philip Jenvey