Пример #1
0
 /**
  * 设置源字符串
  * @param $source
  * @param $source_charset
  * @param $target_charset
  * =
  * @return bool
  */
 static private function SetSource($source, $source_charset = 'utf-8', $target_charset = 'utf-8') {
     self::$sourceCharSet = strtolower($source_charset);
     self::$targetCharSet = strtolower($target_charset);
     self::$simpleResult = array();
     self::$finallyResult = array();
     self::$finallyIndex = array();
     if ($source != '') {
         $rs = TRUE;
         if (preg_match("/^utf/", $source_charset)) {
             self::$sourceString = @iconv('utf-8', UCS2, $source);
         } else if (preg_match("/^gb/", $source_charset)) {
             self::$sourceString = @iconv('utf-8', UCS2, iconv('gb18030', 'utf-8', $source));
         } else if (preg_match("/^big/", $source_charset)) {
             self::$sourceString = @iconv('utf-8', UCS2, iconv('big5', 'utf-8', $source));
         } else {
             $rs = FALSE;
         }
     } else {
         $rs = FALSE;
     }
     return $rs;
 }