HTML5 File api, reading in an xml/text file and displaying it on the page?

You need to pass in the encoding as a string; put quotes around the UTF-8. Also, it’s readAsText, not readAsDataText:

reader.readAsText(f,"UTF-8");

Or you can just leave the encoding off entirely, in which case it will try to auto-detect UTF-16BE or LE, and if it’s not one of those, it will just use UTF-8 by default.

reader.readAsText(f);

Leave a Comment