Tuesday, 1 October 2013

Passing unicode characters to Jython

Passing unicode characters to Jython

I am trying to run a python code on Jython, and this code contains some
Unicode literals. I'd like to pass the code as a String (rather than load
from a file).
It seems that upon exec() method call the unicode characters are converted
to "?" characters:
PythonInterpreter interp = new PythonInterpreter(null, new PySystemState());
System.out.println("â".codePointAt(0)); // outputs 257
interp.exec("print ord(\"â\")"); // outputs 63
I can't seem to find a way how to pass the string to the interpreter
without messing those characters up.

No comments:

Post a Comment