示例#1
0
 /**
  * @param string $sInputString
  * @param string $sInputFromEncoding
  * @param string $sInputToEncoding
  *
  * @return string|bool
  */
 public static function IconvConvertEncoding($sInputString, $sInputFromEncoding, $sInputToEncoding)
 {
     $sIconvOptions = '';
     if (\MailSo\Base\Utils::IsIconvIgnoreSupported()) {
         $sIconvOptions .= '//IGNORE';
     }
     //		if (\MailSo\Base\Utils::IsIconvTranslitSupported())
     //		{
     //			$sIconvOptions .= '//TRANSLIT';
     //		}
     $mResult = @\iconv(\strtoupper($sInputFromEncoding), \strtoupper($sInputToEncoding) . $sIconvOptions, $sInputString);
     if (false === $mResult) {
         if (\MailSo\Log\Logger::IsSystemEnabled()) {
             \MailSo\Log\Logger::SystemLog(array('inc' => \strtoupper($sInputFromEncoding), 'out' => \strtoupper($sInputToEncoding) . $sIconvOptions, 'val' => 500 < \strlen($sInputString) ? \substr($sInputString, 0, 500) : $sInputString, 'hex' => 500 < \strlen($sInputString) ? '-- to long --' : \bin2hex($sInputString)), \MailSo\Log\Enumerations\Type::NOTICE);
         }
         if (\MailSo\Config::$FixIconvByMbstring && \MailSo\Base\Utils::IsMbStringSupported()) {
             $mResult = \MailSo\Base\Utils::MbConvertEncoding($sInputString, $sInputFromEncoding, $sInputToEncoding);
         }
     }
     return $mResult;
 }