PDA

View Full Version : How can I make PHP read special characters sent from Flash correctly?


kozel
04-26-2006, 03:27 PM
Hi,
maybe this has been replied a thousand times, but I could not find any comprehensible answer. My problem is:

I'm sending a string from Flash to PHP (via loadVars.sendAndLoad) which contains some special (czech) characters. PHP simply creates a .txt file containing that string. But when I open this .txt file special characters (žščřáíé...) are substituted by some nonsense strings (á,ů,Å™ etc.) Can anyone give me a suggestion how to prevent these changes.

Thank you in advance.

Kozel

jsebrech
04-26-2006, 03:52 PM
What you're dealing with are codepages. Flash internally uses UTF8 by default. If you submit this to a PHP script that outputs its text as latin1, you will not see the characters appear correctly in the text file.

What you can do is use System.useCodePage = true in flash, which will make it use whatever the user's local code page is. It's a crude hack, it won't always work correctly, but it will get you going.

What you should do is learn about character sets, how they work, how they are encoded, and how to handle using UTF8 in PHP. Two links that could get you going:
The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) (http://www.joelonsoftware.com/articles/Unicode.html)
Converting Web Applications to UTF-8 (http://www.toppa.com/blog/technobabble/233)