apply_aliases($encoding); if ($encoding === 'iso-8859-1') { return utf8_encode($html); } elseif ($encoding === 'utf-8') { return $html; } elseif(isset($g_utf8_converters[$encoding])) { return $this->something_to_utf8($html, $g_utf8_converters[$encoding][0]); } else { die("Unsupported encoding detected: '$encoding'"); }; } function something_to_utf8($html, &$mapping) { for ($i=0; $i < strlen($html); $i++) { $replacement = code_to_utf8($mapping[$html{$i}]); if ($replacement != $html{$i}) { $html = substr_replace($html, $replacement, $i, 1); $i += strlen($replacement) - 1; }; }; return $html; } } ?>