diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-12-25 07:04:38 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-12-25 07:04:38 +0000 |
commit | b4876f5e0422e020d617b77145a492c5bc327f08 (patch) | |
tree | 53a232de142804533aa235f9a34b6add1c829a88 /lib | |
parent | d05217109fb5e909bbd7849bcc799b6404c7c8b0 (diff) | |
download | ruby-b4876f5e0422e020d617b77145a492c5bc327f08.tar.gz |
* lib/csv.rb (CSV::foreach, CSV#initialize): directly use encoding
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/csv.rb | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/csv.rb b/lib/csv.rb index 1ad019a269..266810cb93 100644 --- a/lib/csv.rb +++ b/lib/csv.rb @@ -1203,10 +1203,7 @@ class CSV # but transcode it to UTF-8 before CSV parses it. # def self.foreach(path, options = Hash.new, &block) - encoding = options.delete(:encoding) - mode = "rb" - mode << ":#{encoding}" if encoding - open(path, mode, options) do |csv| + open(path, 'rb', options) do |csv| csv.each(&block) end end @@ -1564,7 +1561,8 @@ class CSV # create the IO object we will read from @io = data.is_a?(String) ? StringIO.new(data) : data # honor the IO encoding if we can, otherwise default to ASCII-8BIT - @encoding = raw_encoding || Encoding.default_internal || + @encoding = options.delete(:internal_encoding) || options.delete(:encoding) || + raw_encoding || Encoding.default_internal || Encoding.default_external # # prepare for building safe regular expressions in the target encoding, |