note 97051 modified in class.domdocument by danbrown
| From: | danbrown@php.net | Date: | Tue, 30 Mar 2010 14:29:35 +0000 |
| Subject: | note 97051 modified in class.domdocument by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-167534@lists.php.net to get a copy of this message | ||
After running into a problem with DomDocument and a UTF-8 encoded input string, a simple work-around
was to convert the input string to ISO-8859-1, run my DOM queries, then convert back to UTF-8:
<?php
$xhtml = 'a UTF-8 encoded string';
$xhtml = utf8_decode($xhtml); // convert UTF-8 string to ISO-8859-1
// doing some DOM manipulation here on $xhtml
$xhtml = utf8_encode($xhtml); // convert ISO-8859-1 string back to UTF-8
?>
Not ideal - but it worked for me.
--was--
After running into a problem with DomDocument and a UTF-8 encoded input string, a simple work-around
was to convert the input string to ISO-8859-1, run my DOM queries, then convert back to UTF-8:
$xhtml = 'a UTF-8 encoded string';
$xhtml = utf8_decode($xhtml); // convert UTF-8 string to ISO-8859-1
// doing some DOM manipulation here on $xhtml
$xhtml = utf8_encode($xhtml); // convert ISO-8859-1 string back to UTF-8
Not ideal - but it worked for me.
http://php.net/manual/en/class.domdocument.php