saveHTMLFile generates empty files

[email protected] (Bernhard Zwischenbrugger) Fri, 05 Nov 2004 10:16:07 +0100
Newsgroups php.xml.dev
Organization Datenküche
Message-ID <[email protected]>
Hi all

I have problems with non ascii characters.
There is no problem if the client sends UTF-8 encoded strings.
But I don't own all clients ;-)

Is there a possibility to check errors before I save the File?

In the examle I try to change a HTML file. If you give öäü (German Umlauts)
as GET Parameter
the html File is destroyed. The saveHTMLFile gives a warning but that's too
late.

There is an other problem with the save method. 
If the Harddisk is full, the save method converts to a delete method ;-)

Bernhard

test.html:
==========
<html>
<body>
</body>
</html>



php program:
============

<?php
$dom=domDocument::loadHTMLFile('test.html');
$body=$dom->getElementsByTagName("body")->item(0);
$textnode=$dom->createTextNode($_GET['umlaut']); //try öäü
$body->appendChild($textnode);
print $dom->saveHTML();

//save changed html file
//if(file is ok and has no iconv errors){     <-- how to do that?
        $dom->saveHTMLFile('test.html')
//}

?>