While using a HTML string directly and a non utf-8 encoding has been specified in the HTML string(as the origin html file is using that encoding).
Then self._parseCharset(response); will return that non utf-8 encoding and try to re-decode the string, thus causing string garbled. So it requried passing incomingEncoding or encoding to the option to make it works correctly or passing a non-decoded Buffer directly to the html property(if this is mostly used for tests, passing Buffer should be a rare case).
Would it be more appropriate to skip the re-encoding operation while passing string to the html property?
While using a HTML
string
directly and a non utf-8 encoding has been specified in the HTMLstring
(as the origin html file is using that encoding).Then
self._parseCharset(response);
will return that non utf-8 encoding and try to re-decode the string, thus causing string garbled. So it requried passingincomingEncoding
orencoding
to the option to make it works correctly or passing a non-decodedBuffer
directly to thehtml
property(if this is mostly used for tests, passingBuffer
should be a rare case).Would it be more appropriate to skip the re-encoding operation while passing
string
to thehtml
property?POC:
output: