Skip to content
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

"\xE2" from ASCII-8BIT to UTF-8 #34

Open
noahkconley opened this issue Sep 21, 2018 · 1 comment
Open

"\xE2" from ASCII-8BIT to UTF-8 #34

noahkconley opened this issue Sep 21, 2018 · 1 comment

Comments

@noahkconley
Copy link

Getting this issue from within the HTMLEntities#decode method from a decrypted csv file. Is there a workaround for this?

@cfurrow
Copy link

cfurrow commented Nov 27, 2021

The problem is that the underlying Ruby code to encode the strings is not handling undefined or invalid values, so the error bubbles up. This is something the gem author could fix (or someone could submit a PR to fix this).

See: https://ruby-doc.org/core-2.5.3/String.html#method-i-encode

# lib/htmlentities/decoder.rb
#...snip
private

def prepare(string) #:nodoc:
  string.to_s.encode(Encoding::UTF_8, invalid: :replace, undef: :replace, replace: '?')
end

#...snip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants