예제 #1
0
 /**
  * @param string $sStr
  *
  * @return string
  */
 public static function CharsetDetect($sStr)
 {
     $mResult = '';
     if (!\MailSo\Base\Utils::IsAscii($sStr)) {
         $mResult = \MailSo\Base\Utils::IsMbStringSupported() && \MailSo\Base\Utils::FunctionExistsAndEnabled('mb_detect_encoding') ? @\mb_detect_encoding($sStr, 'auto', true) : false;
         if (false === $mResult && \MailSo\Base\Utils::IsIconvSupported()) {
             $mResult = \md5(@\iconv('utf-8', 'utf-8//IGNORE', $sStr)) === \md5($sStr) ? 'utf-8' : '';
         }
     }
     return \is_string($mResult) && 0 < \strlen($mResult) ? $mResult : '';
 }
예제 #2
0
파일: Header.php 프로젝트: Git-Host/email
 /**
  * @return string
  */
 public function EncodedValue()
 {
     $sResult = $this->sFullValue;
     if ($this->IsSubject()) {
         if (!\MailSo\Base\Utils::IsAscii($sResult) && \MailSo\Base\Utils::IsIconvSupported() && \function_exists('iconv_mime_encode')) {
             $aPreferences = array('scheme' => \MailSo\Base\Enumerations\Encoding::BASE64_SHORT, 'input-charset' => \MailSo\Base\Enumerations\Charset::UTF_8, 'output-charset' => \MailSo\Base\Enumerations\Charset::UTF_8, 'line-length' => \MailSo\Mime\Enumerations\Constants::LINE_LENGTH, 'line-break-chars' => \MailSo\Mime\Enumerations\Constants::CRLF);
             return \iconv_mime_encode($this->Name(), $sResult, $aPreferences);
         }
     } else {
         if ($this->IsParameterized() && $this->oParameters && 0 < $this->oParameters->Count()) {
             $sResult = $this->sValue . '; ' . $this->oParameters->ToString(true);
         } else {
             if ($this->IsEmail()) {
                 $oEmailCollection = \MailSo\Mime\EmailCollection::NewInstance($this->sFullValue);
                 if ($oEmailCollection && 0 < $oEmailCollection->Count()) {
                     $sResult = $oEmailCollection->ToString(true, false);
                 }
             }
         }
     }
     return $this->NameWithDelimitrom() . $this->wordWrapHelper($sResult);
 }