views:

248

answers:

1

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

+1  A: 

Ummm... I think that is the correct way actually. \u00df is a correct unicode representation of ß. When you json_decode() it back, it will become ß again.

Where is this making problems for you? Is the receiving end not decoding it properly? It should if you use standard json_* functions.

All the examples in the manual show the same thing - characters beyond the ASCII range are turned into numeric sequences.

Pekka
I wasn't aware of the fact that it probably will be translated back by the decode, so i was tracking errors where are none. I just generate the Output, but i later don't process the json object, so probably it will be solved by the other application. Sorry and thanks for your help,i3
i3rutus