summaryrefslogtreecommitdiff
path: root/lib/csv.rb
diff options
context:
space:
mode:
authorKoichi ITO <koic.ito@gmail.com>2020-06-04 12:33:47 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-07-20 02:32:52 +0900
commit08e70126aeca4edcdeab7dc292acda2f50cc41a1 (patch)
treead573ea15c27d271f9de0902bad6edf5b377c8c6 /lib/csv.rb
parentcee10c1b7033f4682b3f4c76220c0c190e70aa1a (diff)
[ruby/csv] Add `invalid: :replace` for `CSV.open` (#130)
This PR adds `invalid: :replace` for `CSV.open`. It is a PR similar to #129. https://github.com/ruby/csv/commit/5bf687341c
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3332
Diffstat (limited to 'lib/csv.rb')
-rw-r--r--lib/csv.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/csv.rb b/lib/csv.rb
index a06c92a1b9..285f7198b7 100644
--- a/lib/csv.rb
+++ b/lib/csv.rb
@@ -962,8 +962,10 @@ class CSV
#
# possible options elements:
# hash form:
- # :undef => :replace # replace undefined conversion
- # :replace => string # replacement string ("?" or "\uFFFD" if not specified)
+ # :invalid => nil # raise error on invalid byte sequence (default)
+ # :invalid => :replace # replace invalid byte sequence
+ # :undef => :replace # replace undefined conversion
+ # :replace => string # replacement string ("?" or "\uFFFD" if not specified)
#
# This method opens an IO object, and wraps that with CSV. This is intended
# as the primary interface for writing a CSV file.
@@ -1026,6 +1028,7 @@ class CSV
# wrap a File opened with the remaining +args+ with no newline
# decorator
file_opts = {universal_newline: false}.merge(options)
+ options.delete(:invalid)
options.delete(:undef)
options.delete(:replace)