Forum: JRuby Character encoding

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
RMan (Guest)
on 2009-05-08 22:23
(Received via mailing list)
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-tp2345113...
Sent from the JRuby - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Yoko H. (Guest)
on 2009-05-08 23:09
(Received via mailing list)
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
This topic is locked and can not be replied to.