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�"