Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

casecmp on UTF-16LE encoded string produces ArrayIndexOutOfBoundsException #1675

tommunist opened this issue May 1, 2014 · 1 comment


Copy link

Having some trouble with UTF-16LE encoded strings in jruby...
Tried the following in jruby-1.7.9:

>> a = 'ABC'.encode('UTF-16LE')
=> "ABC"
>> b = 'ABC'.encode('UTF-16LE')
=> "ABC"
>> b.casecmp(a)

which produced:

Java::JavaLang::ArrayIndexOutOfBoundsException: -1
    from org.jruby.RubyString.multiByteCasecmp(
    from org.jruby.RubyString.casecmp19(
    from org.jruby.RubyString$INVOKER$i$1$0$$INVOKER$i$1$0$casecmp19.gen)
    from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(
    from org.jruby.ast.CallOneArgNode.interpret(
    from org.jruby.ast.NewlineNode.interpret(
    from org.jruby.ast.RootNode.interpret(
    from org.jruby.evaluator.ASTInterpreter.INTERPRET_EVAL(
    from org.jruby.evaluator.ASTInterpreter.evalWithBinding(
    from org.jruby.RubyKernel.evalCommon(
    from org.jruby.RubyKernel.eval19(
    from org.jruby.RubyKernel$INVOKER$s$0$3$$INVOKER$s$0$3$eval19.gen)
    from org.jruby.ast.FCallManyArgsNode.interpret(
... 114 levels...
    from org.jruby.ast.BlockNode.interpret(
    from org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(
    from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(
    from from bin.irb.__file__(bin/irb:13)
    from bin.irb.load(bin/irb)
    from org.jruby.Ruby.runScript(
    from org.jruby.Ruby.runScript(
    from org.jruby.Ruby.runNormally(
    from org.jruby.Ruby.runFromMain(
    from org.jruby.Main.doRunFromMain(
    from org.jruby.Main.internalRun(
    from org.jruby.Main.main(

One thing I did notice is that org.jcodings.EncodingDB has an entry for 'UTF-16LE' but org.jcodings.EncodingList does not contain an entry for 'UTF-16LE'...

Am I doing something strange or is this an issue? I'll continue looking at what might be causing it but would like to know if anyone has seen this before.

Copy link

k77ch7 commented Dec 18, 2014

This works on ruby-1.9.3, ruby-2.0.0, and ruby-2.1.0. But this still doesn't work on master and jruby-1_7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

4 participants