Project

General

Profile

Actions

Bug #4382

closed

Encoding of result string for String#gsub! is not consistent for BINARY

Added by drbrain (Eric Hodel) about 13 years ago. Updated almost 13 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.3dev (2011-02-07 trunk 30814) [x86_64-darwin10.6.0]
Backport:
[ruby-core:35143]

Description

=begin
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.
=end


Files

test_string.rb.sub_bang_encoding.patch (613 Bytes) test_string.rb.sub_bang_encoding.patch Test patch to illustrate the bug drbrain (Eric Hodel), 02/08/2011 05:27 AM

Related issues 1 (0 open1 closed)

Is duplicate of Ruby master - Bug #4380: Encoding of result string for String#gsub! is not consistent for BINARYClosednaruse (Yui NARUSE)02/08/2011Actions
Actions #1

Updated by naruse (Yui NARUSE) about 13 years ago

  • Status changed from Open to Closed

=begin
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
    ASCII-8BIT receivers.

  • string.c (str_gsub): set initial encoding of the buffer as the
    same of the receiver. [ruby-core:35141]
    =end

Actions

Also available in: Atom PDF

Like0
Like0