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: invalidmultibytecharacter: /Â¥/fromorg/jruby/RubyString.java:2817:in`sub!' from org/jruby/RubyString.java:2777:in `sub' from (irb):5:in `evaluate'fromorg/jruby/RubyKernel.java:1107:in `eval' from org/jruby/RubyKernel.java:1507:in `loop'fromorg/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"
cherry-picked to master. Closing. For posterity MRI does not use regexps for string subs and has this dual-use loop where search and replace code is calls either regexp or string stuff. It was pretty invasive to do it that way and it seemed kind of difficult to follow.
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:
JRuby:
JRuby version info:
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
The text was updated successfully, but these errors were encountered: