Re: [Jython-users] cyrillic string
by Samuele Pedroni other posts by this author
Mar 26 2004 1:44PM messages near this date
[Jython-users] cyrillic string
|
[Jython-users] hello
At 13:56 26.03.2004 +0200, Paul Babachanakh wrote:
> Hello!
>
> I'm trying to use Jython (version 2.1) to execute programm on Python
> from Java. I have some problem with cyrillic string.
>
> I run the programm as follow:
>
> import org.python.util.PythonInterpreter;
> import org.python.core.*;
>
> public class TestPy {
> public static void main( String args[] ) {
> System.out.println("Start");
>
> PythonInterpreter interp = new PythonInterpreter();
> interp.exec("str1='Ýòî ñòðîêà1. This is string1 - it is bad'");
> interp.set("str2", new PyString("Ýòî ñòðîêà2. This is string2 - it is
> OK"));
> interp.exec("print str1\nprint str2");
> ß
> System.out.println("Stop");
> }
> }
>
> get the following result
>
> Start
> -B> AB@>:01. This is string1 - it is bad
> Ýòî ñòðîêà2. This is string2 - it is OK
> Stop
>
> str1 has wrong value in Python.
> str2 has right value in Python.
>
> I need to call exec function, but not set. How can I fix my problem?
it's a subtle bug, Java strings passed to exec etc are treated as byte
values' sequences
in some encodings.
One can use \u escapes as a workaround.
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id70&alloc_id638&opÌk
_______________________________________________
Jython-users mailing list
Jython-users@[...].net
https://lists.sourceforge.net/lists/listinfo/jython-users
Thread:
Paul Babachanakh
Samuele Pedroni
|