Encoding of result string for String#gsub! is not consistent for BINARY
When String#sub! is called on a string in BINARY encoding the encoding may 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.
Updated by naruse (Yui NARUSE) about 9 years ago
- Status changed from Open to Closed
This issue was solved with changeset r30876.
Eric, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
string.c (rb_enc_cr_str_buf_cat): remove special treatment of
string.c (str_gsub): set initial encoding of the buffer as the
same of the receiver. [ruby-core:35141]