2

I am reading local text file using input-type-file and FileReader.readAsText(). The problem arises when the local text file contains characters like Ü. In that case it is converted to ï¿. Of course I can set encoding manually to iso8859-1 as a parameter of FileReader.readAsText(File, encoding) but the thing is that I have no clue what kind of encoding user has set on his side.

My question is whether there is an option to determine encoding on client machine ?

Best regards kkris1983

1 Answer 1

3

You'd need to analyze the raw binaries of the text file to have a best guess at what the encoding is. There isn't any libraries for this in javascript AFAIK but you could port one from other languages.

Since that isn't very robust, you should also provide a manual override like Characters not showing correctly? Change encoding:

You can also have smart defaults, for example ISO-8859-1 if you detect it's western windows machine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.