XML character encoding issue with PHP -
i have code creating xml, problem encoding of words á, olá , ção. these characters dont appear correctly , when seek reading xml error displayed relating character.
$dom_doc = new domdocument("1.0", "utf-8"); $dom_doc->preservewhitespace = false; $dom_doc->formatoutput = true; $element = $dom->createelement("hotels"); while ($row = mysql_fetch_assoc($result)) { $contact = $dom_doc->createelement( "m" . $row['id'] ); $nome = $dom_doc->createelement("nome", $row['nome'] ); $data1 = $dom_doc->createelement("data1", $row['data'] ); $data2 = $dom_doc->createelement("data2", $row['data2'] ); $contact->appendchild($nome); $contact->appendchild($data1); $contact->appendchild($data2); $element->appendchild($contact); $dom_doc->appendchild($element);
what can alter prepare problem, using utf-8???
you using utf-8, 8-bit unicode encoding format. though supports 1,112,064 code points in unicode possible there issue here. seek utf-16 standard, idea. see below:
$dom_doc = new domdocument("1.0", "utf-16");
or
$dom_doc = new domdocument("1.0", "iso-10646");
php xml character-encoding
No comments:
Post a Comment