Thanks to visit codestin.com
Credit goes to github.com

Skip to content

String.encode :replace option does not work when encoding to UTF8 #3402

@brianstien

Description

@brianstien

Reproduction

ruby -e 'puts "testing\xC2".encode("UTF-8", :invalid => :replace, :undef => :replace, :replace => "foo123")'

MRI behavior (2.2.3)

2.2.3 :001 > "testing\xC2".encode("UTF-8", :invalid => :replace, :undef => :replace, :replace => "foo123")
 => "testingfoo123"

JRuby behavior (9.0.1.0)

jruby-9.0.1.0 :001 > "testing\xC2".encode("UTF-8", :invalid => :replace, :undef => :replace, :replace => "foo123")
 => "testing�"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions