ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> Jython-users
Jython-users
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

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved