Menu:

Sponsor

Discover Master of Alchemy, our first iPad/iPhone and iPod touch game!

 

Forum's topics

Latest Files

Archives

Top Rated

Categories

Photo Gallery


AMFPHP and MySQL character set

6. Try the different options

Ok, now it's time to try with the different options in the gateway.php file and look at the results in flash.
I will reproduce the effect of inserting the same couple of strings with different parameters passed in the setCharsetHandler. I will write in the input text field these strings for every test:

setCharsetHandler("mbstring","ISO-8859-1","ISO-8859-1");

The result:

setCharsetHandler("mbstring","UTF-8","UTF-8");

The result:

setCharsetHandler("mbstring","ASCII","ACII");

The result:

setCharsetHandler("mbstring","UTF-8","ACII");

The result:

In this example all the strings are inserted correctly in our database (using utf-8), but when amfphp gives the strings back to flash it uses ASCII encoding and for this reason they are not correctly decoded back.
Setting setCharsetHandler("mbstring","UTF-8","UTF-8") will give the correct results in the datagrdi too.

setCharsetHandler("iconv","UTF-8","UTF-8");

Let's try with iconv. The result:

setCharsetHandler("iconv","UTF-8","ISO-8859-1");

The result:

setCharsetHandler("utf8_decode","UTF-8","UTF-8");

The result:

7. Conclusion

  • If your php has libiconv enabled then use iconv has the default encoder.
  • Whenever possible always use UTF-8 encoding both for writing and for reading the database.
  • use utf-8 as default character set for your database in mysql
Download files used in this tutorial

Remember: Never use the System.useCodePage = true