Skip to content

RegexpError: invalid multibyte character for method gsub #2602

@joe81

Description

@joe81

The same error like #2528 for the method gsub:

jruby-1.7.19 :001 > str = 9999.to_s
=> "9999" 
jruby-1.7.19 :002 > str.encoding
 => #<Encoding:US-ASCII> 
jruby-1.7.19 :003 > str.sub("¥", "")
 => "9999" 
jruby-1.7.19 :005 > str.gsub(/¥/, "")
 => "9999" 
jruby-1.7.19 :004 > str.gsub("¥", "")
RegexpError: invalid multibyte character: /Â¥/
    from org/jruby/RubyString.java:3085:in `gsub'
    from org/jruby/RubyString.java:3053:in `gsub'
    from (irb):4: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 /home/joe/.rvm/rubies/jruby-1.7.19/bin/irb:13:in `(root)'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions