Manual: PHP/MySQL and Special characters
Dear fellow webmasters,
It took me a while to get it to work with special characters like ä and ü…
When working with MySQL and PHP forget about storing UTF-8, just save the HTML entities; e.g. ä => ä
Now I will give you a step by step manual how to do it.
1.
My website has UTF-8 encoding, I don't know if this is important but I just mention in case that.
2.
I open the fla source file in the Flash editor and open the Library with the assets (ctrl+l). There you see a list with the next two objects:
titleNormal and titleOver
When you double click one of the items you see under the properties the font information (ctrl+F3).
There you can embed character sets. For Germany I added äÄöÖüÜéß, I even added Basic Latin to make sure all the characters needed are available.
Save and export.
3.
In the XML sheet which I made dynamic with PHP I added this phrase on top:
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?".">"; ?>
4.
I saved the XML/PHP file with TextPad as UNIX,UTF-8
5.
The content management system has simple input fields.
The post request of these I convert with this:
htmlentities($_POST['name']), if you loop through an array use this:
htmlentities($_POST['name'][$i])
6.
Values from the database have to be converted back.
For the input boxes this doesn’t apply, your browser takes care.
For the XML sheet use this:
utf8_encode(html_entity_decode($row['name']))
I am aware this is highly technical but I still hope this information might save your day.
Cordially,
Jeroen Haan
|