From: Alan K. <jyt...@xh...> - 2011-11-14 21:00:20
|
[Joey] > Java 6u17 > sys.version_info == (2, 5, 2, 'final', 0) > Windows XP OK, so you're running on java 1.6, which means that you will benefit from Oti Humbels improvement on retrieving the console encoding[1], which you can access like this >>> sys.stdout.encoding cp437 For you, it should say "utf-8". > I am actually using the interpreter embedded in my Java application. I have > verified in my debugger that I am passing the UTF-8 characters down to > the interpreter without losing anything. > > If I access an attribute that I exposed from the Java level that returns a > string, it indeeds returns things correctly as shown below. > >>>> p.notes > '\u3053\u3093\u306b\u3061\u306f' > >>>> print p.notes > こんにちは OK, so this proves that the output encoding of whatever terminal is compatible with displaying UTF-8. But I'm still not clear you're executing this code. You say its running embedded in a java program, but the examples you post look like command line output? > But if I import the following function it does not work. > > # -*- coding: UTF-8 -*- > def testUTF8(): > print 'こんにちは' Try inserting a "print sys.stdout.encoding" before the other print statement. Alan. [1] http://bugs.jython.org/issue1568 |