evalScriptLet Vs. executeScript

I was trying to pass a non-ascii string to Ruby#evalScriptlet and
receive
an exception (invalid multibyte character (US-ASCII)). The same string
can
be successfully passed to Ruby#executeScript.

Is this the expected behavior? Is there anything I can do to pass an
encoded string to evalScriptlet?

An example program at
https://gist.github.com/4646746#file-jruby-evalscriptlet-vs-executescript

Thanks and Regards
KD

executeScript is meant to simulate as if being called from a
command-line. evalScriptlet is more for internal usage and assumes
runtime instance has been setup with the environment you want.

I recommend you do not use either of these (EmbedUtils is an older
embedding option) and use RedBridge APIs:

https://github.com/jruby/jruby/wiki/RedBridge

This does all you want and more and it has a lot more documentation as
well.

-Tom

On Sun, Jan 27, 2013 at 12:12 AM, Dakshinamurthy K.
[email protected] wrote:

Thanks and Regards
KD


blog: http://blog.enebo.com twitter: tom_enebo
mail: [email protected]

Thanks for the suggestion.

This code is part of a larger project and I prefer not changing it at
this
time. I implemented a workaround - before calling evalScriptlet
converting
the script to ascii.

Still, I would like to know what is happening in this case. The
interpreter
has been setup the same way for both the calls to evalScriptlet and
executeScript.

– KD

The sample I posted is using the default configuration. In the actual
project code, proper ruby configuration object is constructed (including
the encoding) and passed to the the instance.

Even in the sample, executeScript accepts encoded strings whereas
evalScriptlet doesn’t. I will walk through the evalScriptlet and see
what
is happening.

– KD

If I had to guess I would say we pass into some config stuff when we
start JRuby (like flags from the native launcher) the first time which
is not reflected in the no-arg RubyInstanceConfig constructor (which
your example ends up indirectly calling). In particular, I am
guessing we defalt iso8859_1 encoding and you are expecting UTF-8.

-Tom

On Mon, Jan 28, 2013 at 10:48 AM, Dakshinamurthy K.
[email protected] wrote:

– KD

embedding option) and use RedBridge APIs:

I was trying to pass a non-ascii string to Ruby#evalScriptlet and

mail: [email protected]


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


blog: http://blog.enebo.com twitter: tom_enebo
mail: [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs