I'm using the following directive to read txt files, however the texts are coming out broken.
I'm using the following directive to read txt files, however the texts are coming out broken.
Ah, now it's easier =]
You can try the following, I did it here in jsfiddle and it worked.
In this line:
reader.readAsText((onChangeEvent.srcElement || onChangeEvent.target).files[0]);
Replace with this:
reader.readAsBinaryString((onChangeEvent.srcElement || onChangeEvent.target).files[0], 'UTF-8');
Try to check if it works
Well, First of all, in the database is charset with UTF = 8 as well? If yes, it could be the coding of the html file (as the comments colleagues said), but it could also be the encoding of the connection to the database. I have had problems with the second situation above, and in my case it was solved using the following queries right after connecting to the database:
SET NAMES 'utf8'
SET character_set_connection=utf8
SET character_set_client=utf8;
SET character_set_results=utf8
See if that helps you.
Only one detail, with these queries above, accents and other special characters will theoretically be saved and read correctly in the database, so the records that have these symbols , need to be corrected manually, or through of some procedure.
I hope I have helped!