public static function toUtf8($string, $charset) { if (!\GO\Base\Util\String::is8bit($string, $charset)) { return $string; } // $searches = array(); // $replaces = array(); // foreach (self::$map as $key => $values) { //// if($key!='C1') //// continue; // // $replace = ''; // foreach ($values as $val) // $replace.=self::unicodeToUtf8($val); // // $searches[] = chr(hexdec($key)); // //echo hexdec($key).' '; // $replaces[] = $replace; // } // return str_replace($searches, $replaces, $string); $out = ''; $len = strlen($string); for ($i = 0; $i < $len; $i++) { $hex = strtoupper(dechex(ord($string[$i]))); if (isset(self::$map[$hex])) { foreach (self::$map[$hex] as $unicodeHex) { $out .= self::unicodeToUtf8($unicodeHex); } } else { $out .= $string[$i]; } } return $out; }