PDA

View Full Version : POST foreign characters to PHP.


evolution-x
03-10-2008, 01:40 PM
Hi,

Im trying to export a variable from flash through POST with a value that contains some foreign characters such as ÄÖÕÜäöõü.

It all works fine but these specific characters do not appear right.

My php script uses ANSI encoding because when using Unicode the script doesnt run at all :confused:

echo "ÕäöüÜ"; works very well

echo $_POST["theVariable"]; works too but some characters cant be displayed.


Is there a solution to this ?
Please help if you can, it's important.


Thanks ahead and have a wonderful day!
Martin.K

jsebrech
03-11-2008, 09:37 AM
Flash reads and writes UTF-8 by default. This means that on the PHP side you must assume all incoming text from flash is UTF-8, and all outgoing text must also be UTF-8.

There are a number of ways to deal with this:
- set charset to utf-8 in php.ini so a correct encoding header is sent (ignored by flash, but handy in the browser)
- Use the mbstring functions to deal with UTF-8 strings (the default string functions can't deal with UTF-8). With the func_overload directive in php.ini you can replace the built-in string functions with the mbstring functions.
- Use the mbstring or iconv functions to convert between character sets.
- Change the character set settings of your database so when it returns UTF-8 encoded data to PHP, and expects UTF-8 data from PHP (or just convert all PHP data to the text encoding that it actually expects).

None of this is simple, but if you search for unicode on the forums, you should find a lot of information.