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 Encoding. Show all posts
Showing posts with label Encoding. Show all posts
Tuesday, April 28, 2015
Wednesday, September 4, 2013
German Umlauts (ä,ö,ü,ß) corrupt in HTML Mails sent with Outlook 2013 and OXtender 2 for OpenXchange
Today i noticed that HTML Mails I sent from Outlook 2013 looked like this on the receiver side:
The german umlauts (special characters) were somehow misinterpreted as non-printable characters.
How-I-fixed-it:
Looking at the raw mail source content i recognized, there was a lot of css-stuff in mail which seemed to be added by Outlook automatically.
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">ft Word 15 (filtered medium)">
link=3D"#954F72">
-->
I found out, that there's an option in Outlook to tell it to use CSS for formatting or not.
I disabled this option and my HTML mails look OK now.
�ffentliche
�bereinstimmung m��te sein
The german umlauts (special characters) were somehow misinterpreted as non-printable characters.
The original text was:
"Öffentliche Übereinstimmung müßte sein"
How-I-fixed-it:
Looking at the raw mail source content i recognized, there was a lot of css-stuff in mail which seemed to be added by Outlook automatically.
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">ft Word 15 (filtered medium)">
link=3D"#954F72">
=EF=BF=
=BDffentliche =EF=BF=BDbereinstimmung m=EF=BF=BD=EF=BF=BDte sein =
=BDffentliche =EF=BF=BDbereinstimmung m=EF=BF=BD=EF=BF=BDte sein
I found out, that there's an option in Outlook to tell it to use CSS for formatting or not.
I disabled this option and my HTML mails look OK now.
Subscribe to:
Posts (Atom)
