Quantcast

Reg. Non-English string literal in Java code

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Reg. Non-English string literal in Java code

Rathna Kumar
Hi,
I am using bean shell interpreter to execute Java code.
If any string literal in Java code has non-English characters
(say, Russian) then such characters becomes garbled when
the interpreter is executing the code.
Is there a way to support internationalization during
bean shell interpreter execution of Java code ?

Usage of bean shell interpreter
Interpreter interpreter = new Interpreter();
interpreter.eval(javaCode);

Content of javaCode
ArrayList aList = new ArrayList();
aList.add("<RussianCharsHere>");
aList.add("<RussianCharsHere>");

Any help is appreciated.

Thanks
Rathna Kumar R
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Reg. Non-English string literal in Java code

David Lee
Are you sure this is beanshell not javac which is corrupting things ?
Take beanshell out and print your array to see.

#1 guess is that when you save the file its not saving it in a unicode (UTF8
or UTF16) representation so when javac comes along the data is already
corrupted.
You can use unicode escapes to solve this   "\uXXXX\uXXXX ..."  
And possibly (not tested) is to use the  system property  file.encoding to
make sure you file matches javac's expectation.
But you also need a text editor which stores in a known encoding.


----------------------------------------
David A. Lee
[hidden email]
http://www.xmlsh.org

-----Original Message-----
From: Rathna Kumar [mailto:[hidden email]]
Sent: Thursday, November 10, 2011 6:31 AM
To: [hidden email]
Subject: [Beanshell-users] Reg. Non-English string literal in Java code

Hi,
I am using bean shell interpreter to execute Java code.
If any string literal in Java code has non-English characters (say, Russian)
then such characters becomes garbled when the interpreter is executing the
code.
Is there a way to support internationalization during bean shell interpreter
execution of Java code ?

Usage of bean shell interpreter
Interpreter interpreter = new Interpreter(); interpreter.eval(javaCode);

Content of javaCode
ArrayList aList = new ArrayList();
aList.add("<RussianCharsHere>");
aList.add("<RussianCharsHere>");

Any help is appreciated.

Thanks
Rathna Kumar R
----------------------------------------------------------------------------
--
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users


------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Reg. Non-English string literal in Java code

Daniel Leuck
In reply to this post by Rathna Kumar
It's been a while since I looked at it, but it comes down to there being streams where there should be readers and writers in the console and interpreter. It's just a very old part of the code that needs about 30 minutes of attention.

Sent from my iPad

On Nov 10, 2011, at 1:31 AM, Rathna Kumar <[hidden email]> wrote:

> Hi,
> I am using bean shell interpreter to execute Java code.
> If any string literal in Java code has non-English characters
> (say, Russian) then such characters becomes garbled when
> the interpreter is executing the code.
> Is there a way to support internationalization during
> bean shell interpreter execution of Java code ?
>
> Usage of bean shell interpreter
> Interpreter interpreter = new Interpreter();
> interpreter.eval(javaCode);
>
> Content of javaCode
> ArrayList aList = new ArrayList();
> aList.add("<RussianCharsHere>");
> aList.add("<RussianCharsHere>");
>
> Any help is appreciated.
>
> Thanks
> Rathna Kumar R
> ------------------------------------------------------------------------------
> RSA(R) Conference 2012
> Save $700 by Nov 18
> Register now
> http://p.sf.net/sfu/rsa-sfdev2dev1
> _______________________________________________
> Beanshell-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beanshell-users

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Reg. Non-English string literal in Java code

Daniel Leuck
In reply to this post by David Lee
It's Beanshell. The interpreter should be assuming UTF8 and reading the cyrillic chars directly just as XML parsers do by default. Writing non-ASCII chars with Unicode escapes is laborious. It drives me nuts with Japanese (and yes, I know there is tool support but this should be default for all interpreters and compilers these days.) Hopefully we can find some time to fix this.

Sent from my iPad

On Nov 10, 2011, at 3:10 AM, "David Lee" <[hidden email]> wrote:

> Are you sure this is beanshell not javac which is corrupting things ?
> Take beanshell out and print your array to see.
>
> #1 guess is that when you save the file its not saving it in a unicode (UTF8
> or UTF16) representation so when javac comes along the data is already
> corrupted.
> You can use unicode escapes to solve this   "\uXXXX\uXXXX ..."  
> And possibly (not tested) is to use the  system property  file.encoding to
> make sure you file matches javac's expectation.
> But you also need a text editor which stores in a known encoding.
>
>
> ----------------------------------------
> David A. Lee
> [hidden email]
> http://www.xmlsh.org
>
> -----Original Message-----
> From: Rathna Kumar [mailto:[hidden email]]
> Sent: Thursday, November 10, 2011 6:31 AM
> To: [hidden email]
> Subject: [Beanshell-users] Reg. Non-English string literal in Java code
>
> Hi,
> I am using bean shell interpreter to execute Java code.
> If any string literal in Java code has non-English characters (say, Russian)
> then such characters becomes garbled when the interpreter is executing the
> code.
> Is there a way to support internationalization during bean shell interpreter
> execution of Java code ?
>
> Usage of bean shell interpreter
> Interpreter interpreter = new Interpreter(); interpreter.eval(javaCode);
>
> Content of javaCode
> ArrayList aList = new ArrayList();
> aList.add("<RussianCharsHere>");
> aList.add("<RussianCharsHere>");
>
> Any help is appreciated.
>
> Thanks
> Rathna Kumar R
> ----------------------------------------------------------------------------
> --
> RSA(R) Conference 2012
> Save $700 by Nov 18
> Register now
> http://p.sf.net/sfu/rsa-sfdev2dev1
> _______________________________________________
> Beanshell-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beanshell-users
>
>
> ------------------------------------------------------------------------------
> RSA(R) Conference 2012
> Save $700 by Nov 18
> Register now
> http://p.sf.net/sfu/rsa-sfdev2dev1
> _______________________________________________
> Beanshell-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beanshell-users

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Reg. Non-English string literal in Java code

David Lee
I've put literal Japanese characters into strings sent to beanshell and it
worked fine.  So I know it can be done without changes to bsh internals.

Perhaps its using the default encoding ... I always start my java programs
(in this case tomcat) with

export LANG=en_US.UTF-8
java ... -Dfile.encoding=UTF-8  

This sets the default character set to UTF-8 ...


----------------------------------------
David A. Lee
[hidden email]
http://www.xmlsh.org


-----Original Message-----
From: Dan Leuck [mailto:[hidden email]]
Sent: Thursday, November 10, 2011 8:44 AM
To: [hidden email]
Cc: Rathna Kumar; <[hidden email]>
Subject: Re: [Beanshell-users] Reg. Non-English string literal in Java code


It's Beanshell. The interpreter should be assuming UTF8 and reading the
cyrillic chars directly just as XML parsers do by default. Writing non-ASCII
chars with Unicode escapes is laborious. It drives me nuts with Japanese
(and yes, I know there is tool support but this should be default for all
interpreters and compilers these days.) Hopefully we can find some time to
fix this.

Sent from my iPad

On Nov 10, 2011, at 3:10 AM, "David Lee" <[hidden email]> wrote:

> Are you sure this is beanshell not javac which is corrupting things ?
> Take beanshell out and print your array to see.
>
> #1 guess is that when you save the file its not saving it in a unicode
(UTF8

> or UTF16) representation so when javac comes along the data is already
> corrupted.
> You can use unicode escapes to solve this   "\uXXXX\uXXXX ..."  
> And possibly (not tested) is to use the  system property  file.encoding to
> make sure you file matches javac's expectation.
> But you also need a text editor which stores in a known encoding.
>
>
> ----------------------------------------
> David A. Lee
> [hidden email]
> http://www.xmlsh.org
>
> -----Original Message-----
> From: Rathna Kumar [mailto:[hidden email]]
> Sent: Thursday, November 10, 2011 6:31 AM
> To: [hidden email]
> Subject: [Beanshell-users] Reg. Non-English string literal in Java code
>
> Hi,
> I am using bean shell interpreter to execute Java code.
> If any string literal in Java code has non-English characters (say,
Russian)
> then such characters becomes garbled when the interpreter is executing the
> code.
> Is there a way to support internationalization during bean shell
interpreter

> execution of Java code ?
>
> Usage of bean shell interpreter
> Interpreter interpreter = new Interpreter(); interpreter.eval(javaCode);
>
> Content of javaCode
> ArrayList aList = new ArrayList();
> aList.add("<RussianCharsHere>");
> aList.add("<RussianCharsHere>");
>
> Any help is appreciated.
>
> Thanks
> Rathna Kumar R
>
----------------------------------------------------------------------------

> --
> RSA(R) Conference 2012
> Save $700 by Nov 18
> Register now
> http://p.sf.net/sfu/rsa-sfdev2dev1
> _______________________________________________
> Beanshell-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beanshell-users
>
>
>
----------------------------------------------------------------------------
--
> RSA(R) Conference 2012
> Save $700 by Nov 18
> Register now
> http://p.sf.net/sfu/rsa-sfdev2dev1
> _______________________________________________
> Beanshell-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beanshell-users


------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Loading...