I have just upgraded to jruby 1.6.1 and when I run in 1.9 mode, the following function fails when it encounters certain charaters. The job of the function is to strip out unwanted characters and also leading and trailing characters. I am adding the following function to the string class:
class String
def strip_noise()
return if empty?
self.force_encoding('utf-8').mb_chars.normalize(:kd).gsub(/[^\x00-\x7F]/n,'').to_s().strip()
end
end
I have the following test that causes the error to happen:
def test_odd_characters()
assert_equal("", " \xC2\xA0".strip_noise())
end
I get a Java::JavaLang::NegativeArraySizeException: when I run the test.
Is this a bug with jruby or can anyone help me out with a better solution?
I am fairly sure this is a jruby bug as it works in normal ruby 1.9.2, I have created the following jira.