diff options
author | Seiei Miyagi <hanachin@gmail.com> | 2019-11-25 10:06:59 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-07-20 02:32:49 +0900 |
commit | 3c5b67e0db22ec9a15cef6c4961abf6f91373dd3 (patch) | |
tree | 411ce6296968dee8b017b8c6213a424eafb91e75 /lib/csv.rb | |
parent | d57bc03ba98649661c7dedbb46ec2f2bb6bee9be (diff) |
[ruby/csv] Ensuring StringIO's encoding in CSV.generate (#111)
https://github.com/ruby/csv/commit/dbf55ef008
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3332
Diffstat (limited to 'lib/csv.rb')
-rw-r--r-- | lib/csv.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/csv.rb b/lib/csv.rb index 8aa65868b7..c793b8e96a 100644 --- a/lib/csv.rb +++ b/lib/csv.rb @@ -531,12 +531,13 @@ class CSV # plan to output non-ASCII compatible data. # def generate(str=nil, **options) + encoding = options[:encoding] # add a default empty String, if none was given if str str = StringIO.new(str) str.seek(0, IO::SEEK_END) + str.set_encoding(encoding) if encoding else - encoding = options[:encoding] str = +"" str.force_encoding(encoding) if encoding end |