0

I know this aurgement was discussed several times but no one solutions or workarounds works for me :(

I'm using a pdo driver to querying a db on my server. This is the connection:

        new PDO('mysql:host=localhost;dbname=*******',
            '****', '*****', array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));

The option PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8 Already solves a lot of problems before, and I've found it as possible solution as string's econding problems.

But my output is still "dirty" and the operation of json_encode() (next operation to will after the data extraction) over some strings data fail without any chance to fix it, even with some extra options don't solve the problem!

The problem is from how the data are extracted from the db, even a var_Dump() of all the data fetched show how strings are corrupeted, this is an example of a field printed by a var_dump of the query result:

Zup2 Zuppa È composta da diverse qualità di pesce, spesso quello cosiddetto "povero"

How can I solve this issue?

JahStation
  • 893
  • 3
  • 15
  • 35
  • php version is 5.5.9, and the data on the db are well encoded – JahStation Nov 18 '14 at 11:17
  • How should it look like? – Xatenev Nov 18 '14 at 11:17
  • 2
    It's possible the data is already corrupted in database. How did you get it in? – Marek Nov 18 '14 at 11:19
  • Read http://stackoverflow.com/questions/279170/utf-8-all-the-way-through and [Handling Unicode Front To Back In A Web App](http://kunststube.net/frontback/). It's way too ambiguous and broad where exactly what problem is happening here. – deceze Nov 18 '14 at 11:21
  • the corrisponding string of the example taken from the db is:`È composta da diverse qualità di pesce, spesso quello cosiddetto "povero"` – JahStation Nov 18 '14 at 11:21
  • @deceze yes i've already seen those links and i didn't solve my problem :( – JahStation Nov 18 '14 at 11:24
  • setting `` on the visualization pages seem to work for now...but is just an alternative workaround i guess – JahStation Nov 18 '14 at 14:30

0 Answers0