Not sure what you mean by "inconsistent", but in general you have to know the character set before you read the file.
https://www.joelonsoftware.com/2003/10/08/the-absolute-minim...
Guessing will lead to tears.
https://www.joelonsoftware.com/2003/10/08/the-absolute-minim...
Guessing will lead to tears.
The command-line version of ftfy [1] can handle a distinct encoding for each line with a near-zero rate of false positives. (No guarantees the output will be correct, especially if you read it as the wrong single-byte encoding initially, but it will be no worse than what you put in, because it won't replace correct text with incorrect text.)
There is no JS version of ftfy, and there won't be until JS can represent all Unicode characters without surrogates.