0

I am struggling with my json answer as I got different answer when I work localy and on my hosted server (1and1). I use jquery autocomplete and $.getJSON to retrieve data from my database. When I work locally my JSON answer doesn't contain blank line at the begining of my answer and the accentued characters are well interpreted. However when I use same code on my hosted server I got a JSON answer with a blank line at the top of my answer and accentued chars are not well interpreted. The answer of my JSON looks like

[{"id":"17035","label":"45110-Germigny-des-Pr\u00c3\u00a9s","value":"45110-Germigny-des-Pr\u00c3\u00a9s"},{"id":"17041","label":"45110-Saint-Martin-d'Abbat","value":"45110-Saint-Martin-d'Abbat"}]

I set the header of my php script to utf-8 but doesn't help. below the output with non encoded chars1 enter image description here

Any help or clue on that issue?

skunk a
  • 235
  • 1
  • 2
  • 10
  • 1
    The problem is not in the json itself as for example `\u00a9` is the correct value to represent the `©` symbol. The problem occurs before the json is generated so you need to check the database, etc. to see if everything is set to utf8: http://stackoverflow.com/questions/279170/utf-8-all-the-way-through – jeroen Nov 23 '14 at 03:01
  • I followed all instructions in the way through and still got those unicode char. I set the header as UTF8 and encoded the $row like this `$rows[] = array_map("utf8_encode", $row);` of my php script, set utf8mb4 in the DSN like this `define('DSN', 'mysql:host=localhost;dbname=770_cc_v1;charset=utf8mb4');`, my table is in `utf8_general_ci`. Is anyone have an idea/clue? – skunk a Dec 23 '14 at 14:33

0 Answers0