Search code examples
phpmysqldatabasecharacter-encodingsimplepie

Spanish characters not saving in database correctly


I'm going through some feeds of spanish blogs and saving them in a database. For example, the word: Diseño! , I can see it correctly in the script that gets the feeds but when it saves in the database it saves like Diseñó! . I have my database set to utf8 . I think i've followed every single question that looks like this but nothing fix it. I have changed the charset in my html from utf8 to iso-8859 but still, i can see it correctly in the html but not once it saves to the database. Anybody has a solution? Thanks!


Solution

  • At a guess, the page that is the source of the "Diseño!" is probably encoded in iso-8859-1 or windows-1252, and it's being stored in your database without any conversion.

    If that's the case, you need to translate the string from the encoding it's in to utf-8, using something like http://php.net/manual/en/function.mb-convert-encoding.php.