function convert_text($text) { global $debugObject; if (is_object($debugObject)) { $debugObject->debugLogEntry(1); } $converted_text = $text; $sourceCharset = ""; $targetCharset = ""; if ($this->dom) { $sourceCharset = strtoupper($this->dom->_charset); $targetCharset = strtoupper($this->dom->_target_charset); } if (is_object($debugObject)) { $debugObject->debugLog(3, "source charset: " . $sourceCharset . " target charaset: " . $targetCharset); } if (!empty($sourceCharset) && !empty($targetCharset) && strcasecmp($sourceCharset, $targetCharset) != 0) { // Check if the reported encoding could have been incorrect and the text is actually already UTF-8 if (strcasecmp($targetCharset, 'UTF-8') == 0 && $this->is_utf8($text)) { $converted_text = $text; } else { $converted_text = iconv($sourceCharset, $targetCharset, $text); } } return $converted_text; }