Sunday, 14 May 2017

Nodejs convert from any to UTF8 when source encoding is random

What would you suggest to use when there is HTML which can be encoded utf8 or any other encoding and i want to have support for any characters/language, so convert anything to utf8.

Source encoding is unknown. Result must be utf8.

have tried:

https://www.npmjs.com/package/string_decoder

const StringDecoder = require('string_decoder').StringDecoder;
const decoder = new StringDecoder('utf8');
html = decoder.write(html);

Doesn't work, still see some broken chars from e.g. german language, russian too



via Lukas Liesis

No comments:

Post a Comment