Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: Problems with danish char in database >Thread Next - Re: Problems with danish char in database Re: Problems with danish char in databaseTo: NULL Date: 4/6/2008 1:12:00 PM
Tine Müller wrote:
> I have made some improvements. Now all the markers can be find. The only
> problem now is making æ ø å instead of an ?.
>
> I changed:
> // Start XML file, create parent node
> //$dom = new DOMDocument("1.0");
> $dom = new DOMDocument('1.0', 'utf-8');
Have you followed this advice
"Note: DOM extension uses UTF-8 encoding. Use utf8_encode() and
utf8_decode() to work with texts in ISO-8859-1 encoding or Iconv for
other encodings."
in the documentation <URL:http://www.php.net/manual/en/ref.dom.php>?
That means for instance you need to do
header('Content-Type: application/xml');
$doc = new DOMDocument();
$doc->appendChild($doc->createElement('root'));
$doc->documentElement->appendChild($doc->createTextNode(
utf8_encode('æ ø å')));
echo $doc->saveXML();
So unless your data from the database comes out as UTF-8 you need to
make sure you encode it first before passing it to any DOM methods like
createTextNode or setAttribute.
--
Martin Honnen
http://JavaScript.FAQTs.com/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
