-
Notifications
You must be signed in to change notification settings - Fork 115
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
CSV.parse not removing BOM character #43
Comments
BOM is for file not string data. I don't know why some users want to use BOM for string data. |
Right. So I should do:
Thanks very much for your help! Sorry to raise an issue when the issue is with my understanding 👍 |
I had to do this with a file today as well (parsing an export from 新生銀行)
|
I have to manually remove BOM in order to test the response in my rspec. BOM = "\xEF\xBB\xBF"
expect(CSV.parse(response.body.delete_prefix(BOM))).to eq [['abcdefg']] It is not elegant, but maybe it is intended since it says: |
Per @kou 's comment, it's a little curious that I see a mention of using |
If you are rendering CSV output in an API response for download to the user, and you want the CSV to include a BOM marker (to prevent character encoding issues when opening the file in older versions of Excel), then it makes perfect sense for the output to have a UTF-8 BOM marker. So stripping it from the body in tests seems like the way to go. |
If a response body is for download ( |
It looks like there's a bug in CSV 3.0.0 where
parse
with encoding 'bom|utf-8' doesn't remove the bom character (but it seems to be fine on theread
method)The text was updated successfully, but these errors were encountered: