I'm trying to get our chat system to support UTF-8, but I'm failing. If, on the client side, I send the following message, passed through encodeURIComponent
:
- îûôó
And put this on the PHP end:
error_log(print_r(array(
$_POST['message'],
urldecode($_POST['message']),
rawurldecode($_POST['message']),
utf8_decode($_POST['message']),
utf8_decode(urldecode($_POST['message'])),
utf8_decode(rawurldecode($_POST['message']))
), true));
This is the output in my error log:
Array
(
[0] => %C3%AE%C3%BB%C3%B4%C3%B3
[1] => îûôó
[2] => îûôó
[3] => %C3%AE%C3%BB%C3%B4%C3%B3
[4] => îûôó
[5] => îûôó
)
So all is fine. However, if I use these, both copied from Wikipedia (Russian language and Japanese language pages, respectively):
- русский язык
- 日本語
It all goes to hell!
Array
(
[0] => %D1%80%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9%20%D1%8F%D0%B7%D1%8B%D0%BA
[1] => руÑÑкий Ñзык
[2] => руÑÑкий Ñзык
[3] => %D1%80%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9%20%D1%8F%D0%B7%D1%8B%D0%BA
[4] => ??????? ????
[5] => ??????? ????
)
Array
(
[0] => %E6%97%A5%E6%9C%AC%E8%AA%9E
[1] => 日本語
[2] => 日本語
[3] => %E6%97%A5%E6%9C%AC%E8%AA%9E
[4] => ???
[5] => ???
)
What do I need to do to make this work?