From: Michael M Slusarz Date: Thu, 11 Nov 2010 20:59:41 +0000 (-0700) Subject: Remove tag? + * + * @var string + */ + protected $_forced; + + /** * Original charset of data. * * @var string @@ -52,6 +59,7 @@ class Horde_Domhtml throw new Exception('DOM extension is not available.'); } + $this->_forced = null; $this->_origCharset = $charset; $old_error = libxml_use_internal_errors(true); @@ -61,7 +69,8 @@ class Horde_Domhtml if (!is_null($charset)) { if (!$doc->encoding) { - $doc->loadHTML('' . Horde_String::convertCharset($text, $charset, 'UTF-8')); + $this->_forced = ''; + $doc->loadHTML($this->_forced . Horde_String::convertCharset($text, $charset, 'UTF-8')); $this->encoding = 'UTF-8'; } elseif ($doc->encoding != $charset) { /* If libxml can't auto-detect encoding, convert to what it @@ -84,7 +93,11 @@ class Horde_Domhtml */ public function returnHtml() { - return Horde_String::convertCharset($this->dom->saveHTML(), $this->encoding, $this->_origCharset); + $ret = Horde_String::convertCharset($this->dom->saveHTML(), $this->encoding, $this->_origCharset); + + return $this->_forced + ? str_replace($this->_forced, '', $ret) + : $ret; } }