/** * Convert a string between charsets. XML will always be UTF-8 * * @param string Input String * @param string Current char set * @param string Destination char set * @return @e string * @todo [Future] If an error is set in classConvertCharset, show it or log it somehow */ protected function _convertCharsets($text, $original_cset, $destination_cset = "UTF-8") { $original_cset = strtolower($original_cset); $destination_cset = strtolower($destination_cset); $t = $text; //----------------------------------------- // Not the same? //----------------------------------------- if ($destination_cset == $original_cset) { return $t; } if (!is_object(self::$classConvertCharset)) { require_once dirname(__FILE__) . '/classConvertCharset.php'; /*noLibHook*/ self::$classConvertCharset = new classConvertCharset(); //----------------------------------------- // Ok, mb functions only support limited number // of charsets, so if mb functions are enabled // but using e.g. windows-1250, no conversion // ends up happening. Let's force internal. //----------------------------------------- //if ( function_exists( 'mb_convert_encoding' ) ) //{ // self::$classConvertCharset->method = 'mb'; //} //else if ( function_exists( 'iconv' ) ) //{ // self::$classConvertCharset->method = 'iconv'; //} //else if ( function_exists( 'recode_string' ) ) //{ // self::$classConvertCharset->method = 'recode'; //} //else //{ self::$classConvertCharset->method = 'internal'; //} } $text = self::$classConvertCharset->convertEncoding($text, $original_cset, $destination_cset); return $text ? $text : $t; }