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

Closed
brianstien opened this Issue Oct 20, 2015 · 0 comments

Comments

Projects
None yet
2 participants
@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�"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment