htmlentities
htmlentities copied to clipboard
"\xE2" from ASCII-8BIT to UTF-8
Getting this issue from within the HTMLEntities#decode method from a decrypted csv file. Is there a workaround for this?
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