Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.6.4, JRuby 1.6.7
-
Fix Version/s: JRuby 1.7.0.RC1
-
Component/s: Encoding, Java Integration, Standard Library
-
Labels:None
-
Environment:Mac OS X 10.7.4
-
Number of attachments :
Description
String#slice on strings with multibyte characters raises Java::JavaLang::ArrayIndexOutOfBoundsException for certain parameters.
> 'Ã¥'.encoding.to_s
=> "UTF-8"
> 'Ã¥'.slice(0,16)
=> "Ã¥", whereas
> 'Ã¥'.slice(0,17)
=> Java::JavaLang::ArrayIndexOutOfBoundsException
Moreover,
> '1234567890Ã¥'.slice(0,17)
=> "1234567890Ã¥"
> '1234567890Ã¥'.slice(1,17)
=> "234567890Ã¥\x00\x00\x00\x00"
> '1234567890Ã¥'.slice(9,17)
=> Java::JavaLang::ArrayIndexOutOfBoundsException
The examples above works in MRI Ruby 1.9.3.
Could you attach the test case as a file, rather than as inline code?
Also, could you test it on the master, since there have been a lot of fixes involving encoding stuff there?
Thank you.