コード例 #1
0
 /**
  * convert charset (and return charset)
  *
  * @param  Zend_Mime_Part  $_part
  * @param  string          $charset
  * @return string   
  */
 protected static function _appendCharsetFilter(Zend_Mime_Part $_part, $charset)
 {
     if ($charset == 'utf8') {
         $charset = 'utf-8';
     } else {
         if ($charset == 'us-ascii') {
             // us-ascii caused problems with iconv encoding to utf-8
             $charset = self::DEFAULT_FALLBACK_CHARSET;
         } else {
             if (strpos($charset, '.') !== false) {
                 // the stream filter does not like charsets with a dot in its name
                 // stream_filter_append(): unable to create or locate filter "convert.iconv.ansi_x3.4-1968/utf-8//IGNORE"
                 $charset = self::DEFAULT_FALLBACK_CHARSET;
             } else {
                 if (iconv($charset, 'utf-8', '') === false) {
                     // check if charset is supported by iconv
                     $charset = self::DEFAULT_FALLBACK_CHARSET;
                 }
             }
         }
     }
     $_part->appendDecodeFilter(self::_getDecodeFilter($charset));
     return $charset;
 }
コード例 #2
0
 /**
  * convert charset (and return charset)
  *
  * @param  Zend_Mime_Part  $_part
  * @param  array           $_structure
  * @param  string          $_contentType
  * @return string
  */
 protected function _appendCharsetFilter(Zend_Mime_Part $_part, $_structure)
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($_structure, TRUE));
     }
     $charset = isset($_structure['parameters']['charset']) ? $_structure['parameters']['charset'] : self::DEFAULT_FALLBACK_CHARSET;
     if ($charset == 'utf8') {
         $charset = 'utf-8';
     } else {
         if ($charset == 'us-ascii' || stripos($charset, 'iso646') !== FALSE) {
             // us-ascii caused problems with iconv encoding to utf-8
             $charset = self::DEFAULT_FALLBACK_CHARSET;
         } else {
             if (strpos($charset, '.') !== false) {
                 // the stream filter does not like charsets with a dot in its name
                 // stream_filter_append(): unable to create or locate filter "convert.iconv.ansi_x3.4-1968/utf-8//IGNORE"
                 $charset = self::DEFAULT_FALLBACK_CHARSET;
             } else {
                 if (iconv($charset, 'utf-8', '') === false) {
                     // check if charset is supported by iconv
                     $charset = self::DEFAULT_FALLBACK_CHARSET;
                 }
             }
         }
     }
     $_part->appendDecodeFilter($this->_getDecodeFilter($charset));
     return $charset;
 }