UTF8 - PHP / Ajax / HTML Form

Hello all,

I have a simple form which data is stored into the database. That form now works with a HTTP-POST request. I want this functionality now via Ajax, so I send the data via an Ajax-request.

Something strange happens. For example this text-file is in UTF8: http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-demo.txt

When I send this file over the HTTP-Post, everything is stored correctly into the database, and when I retrieve the data, everything seems ok. When I send it over Ajax, I get a list of %u03A3-chars. The PHP-function encode_utf8() does not resolve this problem.

Is there a way how I can fix this? Did I forget to set a flag?

Never mind. Ajax can’t send multybyte utf-8.

I use a pregmatch on serverside to convert it to utf-8.

$retval = utf8_encode( preg_replace("/%u([0-9a-f]{3,4})/i","&#x\\1;",urldecode($retval)) );

It works (thanks to PHP: urldecode - Manual).