-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Milestone
Description
Seeing the following error when attempting to run .sub on a US-ASCII string with a UTF-8 encoded argument string that has a non-ASCII character:
MRI:
1.9.3-p547 :001 > str = 9999.to_s
=> "9999"
1.9.3-p547 :002 > str.encoding
=> #<Encoding:US-ASCII>
1.9.3-p547 :003 > str.sub("¥", "")
=> "9999"JRuby:
jruby-1.7.18 :002 > str = 9999.to_s
=> "9999"
jruby-1.7.18 :003 > str.encoding
=> #<Encoding:US-ASCII>
jruby-1.7.18 :005 > str.sub("¥", "")
RegexpError: invalid multibyte character: /Â¥/
from org/jruby/RubyString.java:2817:in `sub!'
from org/jruby/RubyString.java:2777:in `sub'
from (irb):5:in `evaluate'
from org/jruby/RubyKernel.java:1107:in `eval'
from org/jruby/RubyKernel.java:1507:in `loop'
from org/jruby/RubyKernel.java:1270:in `catch'
from org/jruby/RubyKernel.java:1270:in `catch'
from /Users/nb/.rvm/gems/jruby-1.7.18/bundler/gems/rails-fc40cbbc4aaa/railties/lib/rails/commands/console.rb:110:in `start'
from /Users/nb/.rvm/gems/jruby-1.7.18/bundler/gems/rails-fc40cbbc4aaa/railties/lib/rails/commands/console.rb:9:in `start'
from /Users/nb/.rvm/gems/jruby-1.7.18/bundler/gems/rails-fc40cbbc4aaa/railties/lib/rails/commands/commands_tasks.rb:68:in `console'
from /Users/nb/.rvm/gems/jruby-1.7.18/bundler/gems/rails-fc40cbbc4aaa/railties/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/nb/.rvm/gems/jruby-1.7.18/bundler/gems/rails-fc40cbbc4aaa/railties/lib/rails/commands.rb:17:in `(root)'
from org/jruby/RubyKernel.java:1071:in `require'
from script/rails:1:in `(root)'JRuby version info:
jruby-1.7.18 :006 > `jruby -v`
=> "jruby 1.7.18 (1.9.3p551) 2014-12-22 625381c on Java HotSpot(TM) 64-Bit Server VM 1.8.0-b132 [darwin-x86_64]\n"This is relevant as it manifests itself in the Ruby Money gem at the following location:
https://github.com/RubyMoney/money/blob/master/lib/money/money/formatting.rb#L338
Reactions are currently unavailable