I wanted a PHP script to echo an XML-formatted results of a query to a MySQL database table. The script crashed/stopped when i had german umlaut or special character like ä,ö,ü,ß in a text column in the database
How-I-fixed-it:
There where a couple of steps required for me to make the special characters come through to the client browser.
1. Set the collation of the database table and the char columns to charset "utf8_general_ci"
2. In the PHP-code, force the DOMDocument to be UTF-8: $dom = new DOMDocument("1.0","UTF-8");
3. Set the database queries to be UTF-8: $names=mysql_query('set names utf8');
4. Set the charset of the mysql_connection to be UTF-8: mysqli_set_charset($connection, 'utf8');
5. Tell the client browser that the data is UTF-8 encoded: header('Content-Type: text/xml; charset=utf-8');
Maybe not all steps are really necessary, but once it worked for me, i left it that way :-)
I found some help here:
http://www.winfuture-forum.de/index.php?showtopic=193063
http://php.net/manual/de/domdocument.savexml.php
http://www.mysqltutorial.org/mysql-collation/
This blog is about problems i encountered in everyday life and how i fixed them or worked around them. Sometimes i also just post things to let people out there know about something i think it might be of interest for others than me....
Showing posts with label umlaut. Show all posts
Showing posts with label umlaut. Show all posts
Tuesday, April 28, 2015
Tuesday, December 2, 2014
Facebook does not accept website domains with german umlauts ä,ö,ü - Solution: Convert them to Punicode
I tried to add a Website URL to my facebook page which contains german Umlauts ä,ö,ü. Facebook kept telling me, that the URL is not valid.
How-I-fixed-it:
Convert the Domain URL into Punicode, using tools like:
http://tools.macx.de/tools/idnconvert.html
This makes it look like:
www.xn--neuenbrger-adventsfenster-kwc.de
The funny fact is, after entering this as website URL in Facebook, it's automatically converted back to the original form including the Umlauts :-)
How-I-fixed-it:
Convert the Domain URL into Punicode, using tools like:
http://tools.macx.de/tools/idnconvert.html
This makes it look like:
www.xn--neuenbrger-adventsfenster-kwc.de
The funny fact is, after entering this as website URL in Facebook, it's automatically converted back to the original form including the Umlauts :-)
Subscribe to:
Posts (Atom)