You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Edgar Merino <do...@gmail.com> on 2011/07/16 01:30:25 UTC

Encodings and scripting languages

Hello, I've been working on a project using Apache Pivot and Python for UI
logic. Everything works perfectly, except for encodings. It seems that pivot
only registeres the default system encoding, excluding all others. This is
causing me problems since the application I'm writing is suppose to run in
windows (latin1) and my development machine uses linux (utf-8), forcing me
to manually change the encoding for strings when making production releases.

Has anyone got any information on this issue? I'm able to open a jython
console and use different encodings, but somehow this is not working in
pivot. Perhaps this is not a pivot issue, but an issue with the javax.script
API.


I hope someone has an answer to this, thanks in advance.
Edgar Merino

Re: Encodings and scripting languages

Posted by SYSE | Edvin <es...@syse.no>.
Does it help to start your application with -Dfile.encoding=UTF-8?

-- Edvin

Den 21.07.2011 18:14, skrev Edgar Merino:
> Ok I've been struggling with this for days and can't find a solution:
> suppose I have a python script that uses a utf-8 string, like this:
>
> myString = unicode("canción", "utf-8")
>
> if I run the script in linux it'll work without a problem, but if I run
> it under windows then "myString" will containt gargabe instead of "ó", I
> have to manually open the script in windows and change it, this changes
> encoding when saving the file to iso-8859-1.
>
> I would like to stick with utf-8 for my scripts, but I don't know how to
> handle this type of characters in windows. One solution I've found is to
> use native2ascii in my scripts so my strings will be unicode.
>
> I have also tried setting the encoding declaration in the script itself
> but an exception is throws complaining that I cannot declare the
> encoding when the script is being evaluated (the whole script is a
> string). Is there a way to define an encoding for the script that'll be
> included in a bxml file?
>
>
> Any help is greatly appreaciated!
> Edgar Merino
>
> El 18/07/11 14:27, Edgar Merino escribió:
>> Hello Sandro, I'll be glad to contribute to the project by porting the
>> Hello World! script example to jython, I'll just need some time until
>> I finish this project, but you can count on it!
>>
>> Greg, Sandro: I actually found it's an IDE issue, the files are being
>> copied using UTF-8 for it's encoding, I tried filtering the resources
>> using latin1 (iso-8859-1) but I had the same results, I'll see what I
>> can do and I'll let you know the results as soon as I get them.
>>
>>
>> Thanks for your help!
>> Edgar Merino
>>
>> 2011/7/16 Sandro Martini <sandro.martini@gmail.com
>> <ma...@gmail.com>>
>>
>>     Hi all,
>>     Edgar can you attach here a zip containing a minimal sample to see
>>     the issue ?
>>     Thank you very much.
>>     Ah, on apache-extras I've created some time ago an empty project,
>>     pivot-jython ... are you interested in help us and fill there some
>>     content (non copyrighted, like some minimal example) ? We already
>>     have there other projects for other JVM languages ...
>>
>>     Tell me.
>>
>>     Bye,
>>     Sandro
>>
>>     Il giorno 16/lug/2011 01:30, "Edgar Merino" <donvodka@gmail.com
>>     <ma...@gmail.com>> ha scritto:
>>
>>     > Hello, I've been working on a project using Apache Pivot and
>>     Python for UI
>>     > logic. Everything works perfectly, except for encodings. It
>>     seems that pivot
>>     > only registeres the default system encoding, excluding all
>>     others. This is
>>     > causing me problems since the application I'm writing is suppose
>>     to run in
>>     > windows (latin1) and my development machine uses linux (utf-8),
>>     forcing me
>>     > to manually change the encoding for strings when making
>>     production releases.
>>     >
>>     > Has anyone got any information on this issue? I'm able to open a
>>     jython
>>     > console and use different encodings, but somehow this is not
>>     working in
>>     > pivot. Perhaps this is not a pivot issue, but an issue with the
>>     javax.script
>>     > API.
>>     >
>>     >
>>     > I hope someone has an answer to this, thanks in advance.
>>     > Edgar Merino
>>
>>

Re: Encodings and scripting languages

Posted by Sandro Martini <sa...@gmail.com>.
Hi Edgar,
I'll try to take a look at this feature (
https://issues.apache.org/jira/browse/PIVOT-773 ) if possible for the
2.0.1 release, thank you for the moment.

Bye

Re: Encodings and scripting languages

Posted by Edgar Merino <do...@gmail.com>.
Feature request created, thanks for the help!

El 21/07/11 11:44, Greg Brown escribió:
>> Netbeans 7, but using -Dfile.encoding=UTF-8 as Edvin suggested did the trick... again, it'll be nice to be able to set the encoding of the included script in the bxml file.
>
> That seems like a reasonable feature request.
>

Re: Encodings and scripting languages

Posted by Greg Brown <gk...@verizon.net>.
> Netbeans 7, but using -Dfile.encoding=UTF-8 as Edvin suggested did the trick... again, it'll be nice to be able to set the encoding of the included script in the bxml file.


That seems like a reasonable feature request.


Re: Encodings and scripting languages

Posted by Edgar Merino <do...@gmail.com>.
Netbeans 7, but using -Dfile.encoding=UTF-8 as Edvin suggested did the 
trick... again, it'll be nice to be able to set the encoding of the 
included script in the bxml file.

Thanks for the tip Edvin!

El 21/07/11 11:30, Greg Brown escribió:
>> Ok I've been struggling with this for days and can't find a solution: suppose I have a python script that uses a utf-8 string, like this:
>>
>> myString = unicode("canción", "utf-8")
>>
>> if I run the script in linux it'll work without a problem, but if I run it under windows then "myString" will containt gargabe instead of "ó", I have to manually open the script in windows and change it, this changes encoding when saving the file to iso-8859-1.
> What are you using for an editor?
>

Re: Encodings and scripting languages

Posted by Greg Brown <gk...@verizon.net>.
> Ok I've been struggling with this for days and can't find a solution: suppose I have a python script that uses a utf-8 string, like this:
> 
> myString = unicode("canción", "utf-8")
> 
> if I run the script in linux it'll work without a problem, but if I run it under windows then "myString" will containt gargabe instead of "ó", I have to manually open the script in windows and change it, this changes encoding when saving the file to iso-8859-1.

What are you using for an editor?


Re: Encodings and scripting languages

Posted by Edgar Merino <do...@gmail.com>.
Ok I've been struggling with this for days and can't find a solution: 
suppose I have a python script that uses a utf-8 string, like this:

myString = unicode("canción", "utf-8")

if I run the script in linux it'll work without a problem, but if I run 
it under windows then "myString" will containt gargabe instead of "ó", I 
have to manually open the script in windows and change it, this changes 
encoding when saving the file to iso-8859-1.

I would like to stick with utf-8 for my scripts, but I don't know how to 
handle this type of characters in windows. One solution I've found is to 
use native2ascii in my scripts so my strings will be unicode.

I have also tried setting the encoding declaration in the script itself 
but an exception is throws complaining that I cannot declare the 
encoding when the script is being evaluated (the whole script is a 
string). Is there a way to define an encoding for the script that'll be 
included in a bxml file?


Any help is greatly appreaciated!
Edgar Merino

El 18/07/11 14:27, Edgar Merino escribió:
> Hello Sandro, I'll be glad to contribute to the project by porting the 
> Hello World! script example to jython, I'll just need some time until 
> I finish this project, but you can count on it!
>
> Greg, Sandro: I actually found it's an IDE issue, the files are being 
> copied using UTF-8 for it's encoding, I tried filtering the resources 
> using latin1 (iso-8859-1) but I had the same results, I'll see what I 
> can do and I'll let you know the results as soon as I get them.
>
>
> Thanks for your help!
> Edgar Merino
>
> 2011/7/16 Sandro Martini <sandro.martini@gmail.com 
> <ma...@gmail.com>>
>
>     Hi all,
>     Edgar can you attach here a zip containing a minimal sample to see
>     the issue ?
>     Thank you very much.
>     Ah, on apache-extras I've created some time ago an empty project,
>     pivot-jython ... are you interested in help us and fill there some
>     content (non copyrighted, like some minimal example) ? We already
>     have there other projects for other JVM languages ...
>
>     Tell me.
>
>     Bye,
>     Sandro
>
>     Il giorno 16/lug/2011 01:30, "Edgar Merino" <donvodka@gmail.com
>     <ma...@gmail.com>> ha scritto:
>
>     > Hello, I've been working on a project using Apache Pivot and
>     Python for UI
>     > logic. Everything works perfectly, except for encodings. It
>     seems that pivot
>     > only registeres the default system encoding, excluding all
>     others. This is
>     > causing me problems since the application I'm writing is suppose
>     to run in
>     > windows (latin1) and my development machine uses linux (utf-8),
>     forcing me
>     > to manually change the encoding for strings when making
>     production releases.
>     >
>     > Has anyone got any information on this issue? I'm able to open a
>     jython
>     > console and use different encodings, but somehow this is not
>     working in
>     > pivot. Perhaps this is not a pivot issue, but an issue with the
>     javax.script
>     > API.
>     >
>     >
>     > I hope someone has an answer to this, thanks in advance.
>     > Edgar Merino
>
>

Re: Encodings and scripting languages

Posted by Edgar Merino <do...@gmail.com>.
Hello Sandro, I'll be glad to contribute to the project by porting the Hello
World! script example to jython, I'll just need some time until I finish
this project, but you can count on it!

Greg, Sandro: I actually found it's an IDE issue, the files are being copied
using UTF-8 for it's encoding, I tried filtering the resources using latin1
(iso-8859-1) but I had the same results, I'll see what I can do and I'll let
you know the results as soon as I get them.


Thanks for your help!
Edgar Merino

2011/7/16 Sandro Martini <sa...@gmail.com>

> Hi all,
> Edgar can you attach here a zip containing a minimal sample to see the
> issue ?
> Thank you very much.
> Ah, on apache-extras I've created some time ago an empty project,
> pivot-jython ... are you interested in help us and fill there some content
> (non copyrighted, like some minimal example) ? We already have there other
> projects for other JVM languages ...
>
> Tell me.
>
> Bye,
> Sandro
> Il giorno 16/lug/2011 01:30, "Edgar Merino" <do...@gmail.com> ha
> scritto:
>
> > Hello, I've been working on a project using Apache Pivot and Python for
> UI
> > logic. Everything works perfectly, except for encodings. It seems that
> pivot
> > only registeres the default system encoding, excluding all others. This
> is
> > causing me problems since the application I'm writing is suppose to run
> in
> > windows (latin1) and my development machine uses linux (utf-8), forcing
> me
> > to manually change the encoding for strings when making production
> releases.
> >
> > Has anyone got any information on this issue? I'm able to open a jython
> > console and use different encodings, but somehow this is not working in
> > pivot. Perhaps this is not a pivot issue, but an issue with the
> javax.script
> > API.
> >
> >
> > I hope someone has an answer to this, thanks in advance.
> > Edgar Merino
>

Re: Encodings and scripting languages

Posted by Sandro Martini <sa...@gmail.com>.
Hi all,
Edgar can you attach here a zip containing a minimal sample to see the issue
?
Thank you very much.
Ah, on apache-extras I've created some time ago an empty project,
pivot-jython ... are you interested in help us and fill there some content
(non copyrighted, like some minimal example) ? We already have there other
projects for other JVM languages ...

Tell me.

Bye,
Sandro
Il giorno 16/lug/2011 01:30, "Edgar Merino" <do...@gmail.com> ha scritto:
> Hello, I've been working on a project using Apache Pivot and Python for UI
> logic. Everything works perfectly, except for encodings. It seems that
pivot
> only registeres the default system encoding, excluding all others. This is
> causing me problems since the application I'm writing is suppose to run in
> windows (latin1) and my development machine uses linux (utf-8), forcing me
> to manually change the encoding for strings when making production
releases.
>
> Has anyone got any information on this issue? I'm able to open a jython
> console and use different encodings, but somehow this is not working in
> pivot. Perhaps this is not a pivot issue, but an issue with the
javax.script
> API.
>
>
> I hope someone has an answer to this, thanks in advance.
> Edgar Merino

Re: Encodings and scripting languages

Posted by Greg Brown <gk...@verizon.net>.
This sounds like it could be an IDE issue. Are you sure your IDE is configured to save your source files using the right encoding?


On Jul 15, 2011, at 7:30 PM, Edgar Merino wrote:

> Hello, I've been working on a project using Apache Pivot and Python for UI logic. Everything works perfectly, except for encodings. It seems that pivot only registeres the default system encoding, excluding all others. This is causing me problems since the application I'm writing is suppose to run in windows (latin1) and my development machine uses linux (utf-8), forcing me to manually change the encoding for strings when making production releases.
> 
> Has anyone got any information on this issue? I'm able to open a jython console and use different encodings, but somehow this is not working in pivot. Perhaps this is not a pivot issue, but an issue with the javax.script API.
> 
> 
> I hope someone has an answer to this, thanks in advance.
> Edgar Merino