Re: loadHTML/loadHTMLFile - DOM functions

From: Date: Sun, 17 Sep 2006 13:53:17 +0000
Subject: Re: loadHTML/loadHTMLFile - DOM functions
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-241871@lists.php.net to get a copy of this message
Leonidas Safran wrote:
I tried following: I downloaded the ominous html page, coded it as UTF-8 (with text-editor option) and added a metag-tag declaring utf-8 encoding: <meta http-equiv = 'content-type' content = 'text/html; charset=UTF-8'> I checked that the special characters were written correctly then (actually I had to correct them). Then I used the function: $doc = new DomDocument('1.0', 'UTF-8'); The result is still the same, special chars are displayed wrong. Different wrong than before :-) but still wrong... ("ä" is now "ä"). I tried analogy to do the same with "ISO-8859-1" but it's not getting better... So, fazit, even converting the whole document in UTF-8 and adding UTF-8 charset declaration to it, doesn't help me handling special chars... And what about the img-tags which are converted into what ever invisible chars (empty spaces looking at the source code)...?
Do you have your code somewhere? Another thing I realized that I failed to mention before is that using saveXML($element) will serialize the full element, but outputs it in UTF-8 encoding. Have you tried converting the output of that to the encoding of the original HTML page? Rob

« previous php.general (#241871) next »