Character encoding


#1

Hi,

I develop with Eclipse and I want to embed the JRuby scripting engine in
my
application. I have an issue with accented characters and JRuby.

I initialize my engine like this:
ScriptEngineManager m = new ScriptEngineManager();
ScriptEngine rubyEngine = m.getEngineByName(“jruby”);
ScriptContext context = rubyEngine.getContext();

Then I try something really simple:
context.setAttribute(“label”, “à bientôt”, ScriptContext.ENGINE_SCOPE);

Then when I do puts $label
I get this:
à bientôt

I read everywhere that JRuby uses UTF-8 so why does it output my String
like
that?
Is there something special I should do?
Anybody can help me?

Thanks


View this message in context:
http://www.nabble.com/Character-encoding-tp23451130p23451130.html
Sent from the JRuby - User mailing list archive at Nabble.com.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#2

On Fri, May 8, 2009 at 2:21 PM, RMan removed_email_address@domain.invalid wrote:

Then I try something really simple:
context.setAttribute(“label”, “à bientôt”, ScriptContext.ENGINE_SCOPE);

Then when I do puts $label
I get this:
à bientôt

Did you check your project’s text file encoding setting? This setting
is in a “Resource” section of project’s properties window.
The encoding you used to save the file and the one Eclipse used to
compile must be the same. My blog entry,
http://yokolet.blogspot.com/2008/10/why-did-i-get.html, might help
you.

I read everywhere that JRuby uses UTF-8 so why does it output my String like
that?

JRuby uses platfrom default encoding if you don’t use Ruby 1.9’s m17n
feature, while JRuby engine can handle any Java supported encoding.
However, the file and compilation encoding mismatch causes
incorrect-output troubles.

Hope this helps
-Yoko


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email