处理json_encode中的特殊字符

In my database, there are many special characters like (İstanbul, Yeşilköy, Atatürk and more).

when I directly fetch these data from the database all working fine. Means data remain original but problem occur when I convert these data to JSON using json_encode().

After encoding all these data converted to some strange characters like ?stanbul, Bak?rköy...

But after decodeing (using json_decode) I need the original string which was before encoding(json_encode).

I tried many solutions provided on the web to solve the problem but none of them is fully working in my case.

some solutions I tried-

If not possible to get the original string atleast there should not be any ? like thing(remove these things).

Suggest me something to solve the issue.

This library saved my life(https://github.com/neitanod/forceutf8).

Previously I was using the wrong method to get the issue resolved. toUTF8() function was life saver.

Since PHP 5.4 you can use this :

json_encode( $text, JSON_UNESCAPED_UNICODE );

Use mysqli_set_charset(connection,charset); before mysqli_query();

Example:

mysqli_set_charset( $CONNECTION, "utf8" );

$result_query = mysqli_query( $CONNECTION, $query );