diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | lib/csv.rb | 2 |
2 files changed, 7 insertions, 2 deletions
@@ -1,4 +1,9 @@ -Mon Jul 1 15:04:20 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> +Mon Jul 1 15:05:00 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * lib/csv.rb (CSV#<<): use StringIO#set_encoding instead of creating + new StringIO instance with String#force_encoding, forcing encoding + discards the cached coderange bits and can make further operations + very slow. [ruby-core:55714] [Bug #8585] * ext/stringio/stringio.c (strio_write): keep coderange of ptr->string. diff --git a/lib/csv.rb b/lib/csv.rb index fe153153be..b6d9121146 100644 --- a/lib/csv.rb +++ b/lib/csv.rb @@ -1655,7 +1655,7 @@ class CSV if @io.is_a?(StringIO) and output.encoding != raw_encoding and (compatible_encoding = Encoding.compatible?(@io.string, output)) - @io = StringIO.new(@io.string.force_encoding(compatible_encoding)) + @io.set_encoding(compatible_encoding) @io.seek(0, IO::SEEK_END) end @io << output |