Bug #4382: Encoding of result string for String#gsub! is not consistent f=
or BINARY
http://redmine.ruby-lang.org/issues/show/4382

Author: Eric Hodel
Status: Open, Priority: Normal
Category: core
ruby -v: ruby 1.9.3dev (2011-02-07 trunk 30814) [x86_64-darwin10.6.0]

When String#sub! is called on a string in BINARY encoding the encoding ma=
y be changed to the replacement encoding.

This is due to rb_enc_compatible()

If this is a feature the documentation should be updated to indicate this=
.

Attached is a test patch.


----------------------------------------
http://redmine.ruby-lang.org
SW5kZXg6IHRlc3QvcnVieS90ZXN0X3N0cmluZy5yYgo9PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09Ci0tLSB0ZXN0L3J1YnkvdGVzdF9zdHJpbmcucmIJKHJldmlz
aW9uIDMwODE0KQorKysgdGVzdC9ydWJ5L3Rlc3Rfc3RyaW5nLnJiCSh3b3Jr
aW5nIGNvcHkpCkBAIC0xMzA4LDYgKzEzMDgsMTggQEAgY2xhc3MgVGVzdFN0
cmluZyA8IFRlc3Q6OlVuaXQ6OlRlc3RDYXNlCiAgICAgYXNzZXJ0KGEudW50
cnVzdGVkPykKICAgZW5kCiAKKyAgZGVmIHRlc3Rfc3ViX2JhbmdfZW5jb2Rp
bmcKKyAgICBhID0gUygiYSIpCisgICAgYS5mb3JjZV9lbmNvZGluZyBFbmNv
ZGluZzo6QklOQVJZCisKKyAgICByID0gJyAnCisgICAgci5mb3JjZV9lbmNv
ZGluZyBFbmNvZGluZzo6VVRGXzgKKworICAgIGEuc3ViISgvYS8pIGRvIHIg
ZW5kCisKKyAgICBhc3NlcnRfZXF1YWwgRW5jb2Rpbmc6OkJJTkFSWSwgYS5l
bmNvZGluZworICBlbmQKKwogICBkZWYgdGVzdF9zdWNjCiAgICAgYXNzZXJ0
X2VxdWFsKFMoImFiZCIpLCBTKCJhYmMiKS5zdWNjKQogICAgIGFzc2VydF9l
cXVhbChTKCJ6IiksICAgUygieSIpLnN1Y2MpCg==