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

Closed
tommunist opened this issue May 1, 2014 · 1 comment
Closed

Comments

@tommunist
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(RubyString.java:1661)
    from org.jruby.RubyString.casecmp19(RubyString.java:1636)
    from org.jruby.RubyString$INVOKER$i$1$0$casecmp19.call(RubyString$INVOKER$i$1$0$casecmp19.gen)
    from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:326)
    from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170)
    from org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57)
    from org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
    from org.jruby.ast.RootNode.interpret(RootNode.java:129)
    from org.jruby.evaluator.ASTInterpreter.INTERPRET_EVAL(ASTInterpreter.java:95)
    from org.jruby.evaluator.ASTInterpreter.evalWithBinding(ASTInterpreter.java:184)
    from org.jruby.RubyKernel.evalCommon(RubyKernel.java:1156)
    from org.jruby.RubyKernel.eval19(RubyKernel.java:1119)
    from org.jruby.RubyKernel$INVOKER$s$0$3$eval19.call(RubyKernel$INVOKER$s$0$3$eval19.gen)
    from org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:180)
    from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:70)
    from org.jruby.ast.FCallManyArgsNode.interpret(FCallManyArgsNode.java:60)
... 114 levels...
    from org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
    from org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74)
    from org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:182)
    from org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:198)
    from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:326)
    from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170)
    from from bin.irb.__file__(bin/irb:13)
    from bin.irb.load(bin/irb)
    from org.jruby.Ruby.runScript(Ruby.java:811)
    from org.jruby.Ruby.runScript(Ruby.java:804)
    from org.jruby.Ruby.runNormally(Ruby.java:673)
    from org.jruby.Ruby.runFromMain(Ruby.java:522)
    from org.jruby.Main.doRunFromMain(Main.java:395)
    from org.jruby.Main.internalRun(Main.java:290)
    from org.jruby.Main.run(Main.java:217)
    from org.jruby.Main.main(Main.java:197)

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.

@k77ch7
Copy link
Contributor

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
Projects
None yet
Development

No branches or pull requests

4 participants