Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 132
Add CSV::InvalidEncodingError#287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -113,11 +113,11 @@ def test_open_encoding_invalid | ||
| file << "\u{1F600},\u{1F601}" | ||
| end | ||
| CSV.open(@input.path, encoding: "EUC-JP") do |csv| | ||
| error = assert_raise(CSV::MalformedCSVError) do | ||
| error = assert_raise(CSV::InvalidEncodingError) do | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you also change the below assert_equal([Encoding::EUC_JP,"Invalid byte sequence in EUC-JP in line 1."],[error.encoding,error.message]) | ||
| csv.shift | ||
| end | ||
| assert_equal("Invalid byte sequence in EUC-JP in line 1.", | ||
| error.message) | ||
| assert_equal([Encoding::EUC_JP, "Invalid byte sequence in EUC-JP in line 1."], | ||
| [error.encoding, error.message]) | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -280,12 +280,12 @@ def test_row_separator_detection_with_invalid_encoding | ||
| def test_invalid_encoding_row_error | ||
| csv = CSV.new("valid,x\rinvalid,\xF8\r".force_encoding("UTF-8"), | ||
| encoding: "UTF-8", row_sep: "\r") | ||
| error = assert_raise(CSV::MalformedCSVError) do | ||
| error = assert_raise(CSV::InvalidEncodingError) do | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto. | ||
| csv.shift | ||
| csv.shift | ||
| end | ||
| assert_equal("Invalid byte sequence in UTF-8 in line 2.", | ||
| error.message) | ||
| assert_equal([Encoding::UTF_8, "Invalid byte sequence in UTF-8 in line 2."], | ||
| [error.encoding, error.message]) | ||
| end | ||
| def test_string_input_transcode | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding a reader for the target encoding?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't get the target encoding if we don't set it to
@encoding. (See the above suggestion.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops!