0

When I echo some Turkish characters like:

echo "ÇŞİĞÖÜ, çşıüğö"; 

There is no problem:
http://i.hizliresim.com/kj9kov.png
But when I encode this string in a JSON array, and put the encoded string in mysql db, it shows like:
{"otherComments":"u00c7u015eu0130u011eu00d6u00dc, u00e7u015fu0131u00fcu011fu00f6"}

and when I do not encode it in a JSON array, it just shows "?" instead of Turkish characters.
I already have this code in my php file:

header('Content-Type: text/html; charset=utf8');

I have no idea what else to do.

This is the code in my dbconnect file:

    mysql_query("SET NAMES 'utf8'", $this->con);
    mysql_query("SET CHARACTER SET utf8", $this->con);
    mysql_query("SET COLLATION_COLLECTION='utf8_turkish_ci'", $this->con);
    mysql_select_db("mehmeta3_team6", $this->con);

The settings for the selected schema:
http://i.hizliresim.com/gkrAZN.png

The settings for the table and the column:
http://i.hizliresim.com/YvQlrE.png

O. Jones
  • 103,626
  • 17
  • 118
  • 172
  • 1
    Check that you have set UTF-8 as the db: connection/db name/table/column charset. – JimL Feb 28 '15 at 13:40
  • check the database whether the datas are stored in turkis or ?? .. it it is ?? then add N before the values in insert Query... – Sarath Feb 28 '15 at 13:42
  • Related: http://stackoverflow.com/a/279279/1935077 – Petr R. Feb 28 '15 at 13:45
  • Jiml, I updated my question. I already have done all you said. –  Feb 28 '15 at 14:04
  • I made a mistake in this line mysql_query("SET COLLATION_COLLECTION='utf8_turkish_ci'", $this->con); it should be connection, not collection :) –  Feb 28 '15 at 15:25
  • How did you create the JSON? It should have only utf8 characters, not "uxxxx" encodings. `$json = json_encode($string);` is all it takes in PHP. All accented Turkish letters are 2 bytes in utf8: http://mysql.rjweb.org/doc.php/charcoll#turkish . – Rick James Mar 01 '15 at 01:12

1 Answers1

2
its not the db side problem

when you convert it to json format echo that string you will see it converts it to some different format may be to ascii values of those special characters. even if you decode that result it will produce a different result not the strin you encode. i think try to insert in the database without encodin i mean simple string like ÇŞİĞÖÜ may be that can work

Atif
  • 280
  • 1
  • 11