I have a webservice that produce XML result.
I have been working on this site till now, because locally (in my machine) it is working in another way as in the server…
The server have english OS, my machine have hungarian OS (win1250 or iso-8859-2).
So I must reconfigured the db access (set client encoding to utf) to preserve hungarian characters like “ő”, “ű”…
The input is ok now, only the output produce errors…
In the english server this code aborted on error:
$s = "\xf5t\xdb";
$doc = new DOMDocument('1.0', 'iso-8859-2');
$doc->formatOutput = true;
$m = $doc->createElement('package');
$doc->appendChild($m);
$n = $doc->createElement('Msg');
$m->appendChild($n);
$n->nodeValue = $s;
$xs = $doc->saveXML();
echo($xs);
the error was:
PHP Warning: DOMDocument::saveXML()
[<a href='domdocument.savexml'>domdocument.savexml</a>]:
output conversion failed due to conv error, bytes 0xF5 0xDB 0x3C 0x2F
I don’t know how to produce “ő” and “ű” characters in the output.
I can show them:
$s = "\xf5t\xdb";
echo($s."<br>");
But xml generation failed, not matter I use SimpleXML, or Dom…
What can be the solution?
Thanks for every idea: dd
If your data uses utf8, can’t you produce utf8 xml instead of iso-8859-2?
Else, you’ll have to use mb_convert_encoding ()