/**
  * @param string $str
  * @param string $from_encoding
  * @param string $to_encoding
  * @return string
  */
 function ConvertEncoding($str, $from_encoding, $to_encoding)
 {
     // global $mbserror;
     // $from_encoding = ($from_encoding) ? $from_encoding : $GLOBALS[MailDefaultCharset];
     // $to_encoding = ($to_encoding) ? $to_encoding : $GLOBALS[MailOutputCharset];
     $from_encoding = $from_encoding == 'default' ? $GLOBALS[MailDefaultCharset] : $from_encoding;
     $to_encoding = $to_encoding == 'default' ? $GLOBALS[MailOutputCharset] : $to_encoding;
     $output =& $str;
     if (strtolower($from_encoding) == strtolower($to_encoding) || strlen($from_encoding) < 1) {
         return $output;
     }
     if (function_exists('mb_convert_encoding') && USE_MBSTRING) {
         return ConvertUtils::ClassMb_convert_encoding($from_encoding, $to_encoding, $str);
     }
     if (function_exists('iconv') && USE_ICONV) {
         return ConvertUtils::ClassIconv($from_encoding, $to_encoding, $str);
     }
     require_once WM_ROOTPATH . 'common/class_i18nstring.php';
     $i18Str =& new I18nString($str, $from_encoding);
     return $i18Str->GetText($to_encoding);
 }
 /**
  * @return string
  */
 function GetTextAsUtf8()
 {
     if (function_exists('utf8_encode') && $this->DefaultCodePage == CPAGE_ISO8859_1) {
         $this->_text[CPAGE_UTF8] = utf8_encode($this->_text[$this->DefaultCodePage]);
         return $this->_text[CPAGE_UTF8];
     }
     if (function_exists('mb_convert_encoding') && USE_MBSTRING) {
         $this->_text[CPAGE_UTF8] = ConvertUtils::ClassMb_convert_encoding($this->DefaultCodePage, CPAGE_UTF8, $this->_text[$this->DefaultCodePage]);
         return $this->_text[CPAGE_UTF8];
     }
     if (function_exists('iconv') && USE_ICONV) {
         $this->_text[CPAGE_UTF8] = ConvertUtils::ClassIconv($this->DefaultCodePage, CPAGE_UTF8, $this->_text[$this->DefaultCodePage]);
         return $this->_text[CPAGE_UTF8];
     }
     $utf8MappingList =& $this->GetUtf8MappingList();
     if (in_array($this->DefaultCodePage, $utf8MappingList)) {
         require_once WM_ROOTPATH . 'common/utf8decode/' . $this->DefaultCodePage . '.php';
         $this->_text[CPAGE_UTF8] = call_user_func('charset_decode_' . str_replace('-', '_', $this->DefaultCodePage), $this->_text[$this->DefaultCodePage]);
         return $this->_text[CPAGE_UTF8];
     }
     return $this->_text[$this->DefaultCodePage];
 }