Problem with Utf 8 in reading txt file

Asked

Viewed 697 times

2

  • What is your programming editor? Saving in which charset ?

  • even eclipse use.

  • In Eclipse when saving the file or in another SAVE option you must have to save as UTF-8

  • I think it’s in Windows > Preferences, in the left menu go to Web, HTML FILES and on the right choose the Encoding you have: UNICODE(UTF-8)

  • Change to <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" > to see if it works. If it does, that’s exactly what @Zoom said.

  • did not solve, @Zoom did not find the option when arriving in files on the right has nothing related to this.

  • I found it, but it didn’t work...

  • Put the part of HTML that has the error string to see if there are any additional problems in your code.

  • I think the problem is because I am reading txt file, and playing in a string... I tested any text in html and it worked, some solution for javascript?

  • I think I’ll have to open another topic, because I’m using a directive at the angle to do the reading, but look at the code I’m using: http://jsfiddle.net/alexsuch/6aG4x/

  • I would suggest you [Dit] this question and for all the real conditions of the problem code, taking advantage that no one answered anything yet. Put all the details and code in the question itself.

Show 6 more comments

2 answers

1


Ah, now it’s easier =]

You can try the following, I did here on jsfiddle and it worked.

In this line:

reader.readAsText((onChangeEvent.srcElement || onChangeEvent.target).files[0]);

Replaces by this:

reader.readAsBinaryString((onChangeEvent.srcElement || onChangeEvent.target).files[0], 'UTF-8');

Try to see if it works

-2

Good, First of all, in the database is charset UTF=8 too? If yes, it may be the html file encoding (as the comment colleagues said), but it may also be the encoding of the connection to the database. I already had problems with the second situation above, and in my case it was solved using the following queries soon 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.

Just one detail, with these queries above, the accents and other special characters, theoretically, will be saved and read correctly in the database, so the records that are with these symbols , will need to be corrected manually, or through some previous.

I hope I’ve helped!

  • I just edited the question...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.