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

"David Lee" <[email protected]> Thu, 10 Nov 2011 09:27:35 -0500
Newsgroups gmane.comp.java.beanshell.user
Message-ID <[email protected]>
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
[email protected]
http://www.xmlsh.org


-----Original Message-----
From: Dan Leuck [mailto:[email protected]] 
Sent: Thursday, November 10, 2011 8:44 AM
To: [email protected]
Cc: Rathna Kumar; <beanshell-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
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" <[email protected]> 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
> [email protected]
> http://www.xmlsh.org
> 
> -----Original Message-----
> From: Rathna Kumar [mailto:[email protected]] 
> Sent: Thursday, November 10, 2011 6:31 AM
> To: beanshell-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> 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
> Beanshell-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> 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
> Beanshell-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> 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