json_encode with mysql content and umlauts in utf-8
Posted
by i3rutus
on Stack Overflow
See other posts from Stack Overflow
or by i3rutus
Published on 2010-05-06T18:20:26Z
Indexed on
2010/05/06
18:28 UTC
Read the original article
Hit count: 581
Hey,
i feel my beard growing while trying to find out the Problem here.
Basic the Problem is, that Umlauts/Special Signs äöß ... don't work. I guess everyone is sick and tired of that questions but all the solutions found online don't seem to work.
Im having utf-8 content in a utf-8 Mysql Database. I feel the Problem ist somewhere in the Database connection but i just can't figure out.
character_set_client utf8
character_set_connection utf8
character_set_database utf8
character_set_filesystem binary
character_set_results utf8
character_set_server latin1
character_set_system utf8
Im not sure if the problem is the latin1 for character_set_server because im not into that mysql stuff. I also dont know how to change cause i can't access the mysql server's config files.
Whatever is confusing me, that if i get my results from the Database and echo it, print_r gives the right result.
ini_set('default_charset','utf-8');
header('Content-Type: text/plain; > charset=utf-8');
Firefox says char encode is utf-8 but if when i output:
print_r($listnew);
echo json_encode($listnew[5]);
print_r results everything right but json_encode does wrong.
print_r:
[5] => Array (
[id] => 5
[data] => U-Bahnhof Theresienstraße
[size] => 17
)
json_encode:
{"id":5,"data":"U-Bahnhof Theresienstra\u00dfe","size":17}
i know json_encode needs a utf-8 string to work properly there and i feel im having a encode trouble here but i just can't firgure out where it is.
Any help would be appreciated,
thanks in advance.
i3
© Stack Overflow or respective owner