-
Notifications
You must be signed in to change notification settings - Fork 13
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
Encoding::CompatibilityError when csv in UTF-16 format #17
Comments
Could you provide an example test case that throws this error? Thank you
for noticing this and bringing this to my attention.
…On Fri, May 12, 2023 at 20:33 Maksym ***@***.***> wrote:
In PR Use String#start_with? to detect leading special character #12
<#12> the
starts_with_special_character? implementation was changed to use
start_with? which throw an error in case CSV in UTF-16LE format
Encoding::CompatibilityError:
incompatible character encodings: UTF-16LE and UTF-8
—
Reply to this email directly, view it on GitHub
<#17>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABBQJZAVSYNSH6ZGO5QCOILXFY32DANCNFSM6AAAAAAX7RKAUQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Hey @zvory, require 'csv'
require 'csv-safe'
class MyCSV
def self.generate_multiplatform
CSVSafe.generate(col_sep: "\t") { |csv| yield csv }.encode('utf-16le').prepend("\xFF\xFE".force_encoding('utf-16le'))
end
end
csv = MyCSV.generate_multiplatform do |c|
c << ['Вода', 'Water', '💧']
end
CSVSafe.parse(csv, col_sep: "\t", encoding: 'utf-16le') which throw the error
|
Ah unfortunately I'm way busier than I expected and really don't have a moment to spare. I'm going to try to make time for fixing this but I don't know when I'll be able to. If you put up a PR though I'll review it and try to get it merged. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In PR
Use String#start_with? to detect leading special character
#12 thestarts_with_special_character?
implementation was changed to usestart_with?
which throw an error in case CSV in UTF-16LE formatThe text was updated successfully, but these errors were encountered: