當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Mime::isPrintable方法代碼示例

本文整理匯總了PHP中Zend_Mime::isPrintable方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Mime::isPrintable方法的具體用法?PHP Zend_Mime::isPrintable怎麽用?PHP Zend_Mime::isPrintable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend_Mime的用法示例。


在下文中一共展示了Zend_Mime::isPrintable方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _encodeHeader

 /**
  * Encode header fields
  *
  * Encodes header content according to RFC1522 if it contains non-printable
  * characters.
  *
  * @param  string $value
  * @return string
  */
 protected function _encodeHeader($value)
 {
     if (\Zend_Mime::isPrintable($value)) {
         return $value;
     } else {
         /**
          * Next strings fixes the problems
          * According to RFC 1522 (http://www.faqs.org/rfcs/rfc1522.html)
          */
         $quotedValue = '';
         $count = 1;
         for ($i = 0; strlen($value) > $i; $i++) {
             if ($value[$i] == '?' or $value[$i] == '_' or $value[$i] == ' ') {
                 $quotedValue .= str_replace(array('?', ' ', '_'), array('=3F', '=20', '=5F'), $value[$i]);
             } else {
                 $quotedValue .= $this->encodeQuotedPrintable($value[$i]);
             }
             if (strlen($quotedValue) > $count * \Zend_Mime::LINELENGTH) {
                 $count++;
                 $quotedValue .= "?=\n =?" . $this->_charset . '?Q?';
             }
         }
         return '=?' . $this->_charset . '?Q?' . $quotedValue . '?=';
     }
 }
開發者ID:sb15,項目名稱:utils,代碼行數:34,代碼來源:EmailFix.php

示例2: _encodeHeader

 /**
  * Encode header fields
  *
  * Encodes header content according to RFC1522 if it contains non-printable
  * characters.
  *
  * @param  string $value
  * @return string
  */
 protected function _encodeHeader($value)
 {
     if (Zend_Mime::isPrintable($value)) {
         return $value;
     } else {
         $base64Value = base64_encode($value);
         return "=?" . $this->_charset . "?B?" . $base64Value . "?=";
     }
 }
開發者ID:kangza,項目名稱:hagtag,代碼行數:18,代碼來源:Mail.php

示例3: _encodeHeader

 /**
  * Encode header fields
  *
  * Encodes header content according to RFC1522 if it contains non-printable
  * characters.
  *
  * @param  string $value
  * @return string
  */
 protected function _encodeHeader($value)
 {
     if (Zend_Mime::isPrintable($value)) {
         return $value;
     } else {
         $quotedValue = Zend_Mime::encodeQuotedPrintable($value, 400);
         $quotedValue = str_replace(array('?', ' ', '_'), array('=3F', '=20', '=5F'), $quotedValue);
         return '=?' . $this->_charset . '?Q?' . $quotedValue . '?=';
     }
 }
開發者ID:BGCX261,項目名稱:zhongyycode-svn-to-git,代碼行數:19,代碼來源:Mail.php

示例4: _encodeHeader

 protected function _encodeHeader($value)
 {
     if (Zend_Mime::isPrintable($value)) {
         return $value;
     } else {
         $quotedValue = Zend_Mime::encodeQuotedPrintable($value);
         $quotedValue = str_replace(array('?', ' '), array('=3F', '=20'), $quotedValue);
         $quotedValue = rawurlencode($quotedValue);
         $quotedValue = str_replace('%3D%0A', '', $quotedValue);
         $quotedValue = rawurldecode($quotedValue);
         $quotedValue = '=?' . $this->_charset . '?Q?' . $quotedValue . '?=';
     }
     return $quotedValue;
 }
開發者ID:rdallasgray,項目名稱:bbx,代碼行數:14,代碼來源:Mail.php

示例5: _encodeHeader

 /**
  * Encode header fields
  *
  * Encodes header content according to RFC1522 if it contains non-printable
  * characters.
  *
  * @param  string $value
  * @return string
  */
 protected function _encodeHeader($value)
 {
     if (Zend_Mime::isPrintable($value) === false) {
         if ($this->getHeaderEncoding() === Zend_Mime::ENCODING_QUOTEDPRINTABLE) {
             $value = Zend_Mime::encodeQuotedPrintableHeader($value, $this->getCharset(), Zend_Mime::LINELENGTH, Zend_Mime::LINEEND);
         } else {
             $value = Zend_Mime::encodeBase64Header($value, $this->getCharset(), Zend_Mime::LINELENGTH, Zend_Mime::LINEEND);
         }
     }
     return $value;
 }
開發者ID:kaseya-university,項目名稱:efront,代碼行數:20,代碼來源:Mail.php

示例6: testIsPrintable_isPrintable

 public function testIsPrintable_isPrintable()
 {
     $this->assertTrue(Zend_Mime::isPrintable('Test without special chars'));
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:4,代碼來源:MimeTest.php

示例7: _encodeHeader

 /**
  * Encode header fields
  *
  * Encodes header content according to RFC1522 if it contains non-printable
  * characters.
  *
  * @param  string $value
  * @return string
  */
 protected function _encodeHeader($value)
 {
     if (Zend_Mime::isPrintable($value)) {
         return $value;
     } elseif ($this->_encodingOfHeaders === Zend_Mime::ENCODING_QUOTEDPRINTABLE) {
         $quotedValue = Zend_Mime::encodeQuotedPrintable($value);
         $quotedValue = str_replace(array('?', ' ', '_'), array('=3F', '=20', '=5F'), $quotedValue);
         return '=?' . $this->_charset . '?Q?' . $quotedValue . '?=';
     } elseif ($this->_encodingOfHeaders === Zend_Mime::ENCODING_BASE64) {
         return '=?' . $this->_charset . '?B?' . Zend_Mime::encodeBase64($value) . '?=';
     } else {
         /**
          * @todo 7Bit and 8Bit is currently handled the same way.
          */
         return $value;
     }
 }
開發者ID:ankuradhey,項目名稱:dealtrip,代碼行數:26,代碼來源:Mail.php

示例8: assertMailHeaderConformsToRfc

 /**
  * Assertion that checks if a given mailing header string is RFC conform.
  *
  * @param  string $header
  * @return void
  */
 protected function assertMailHeaderConformsToRfc($header)
 {
     $this->numAssertions++;
     $parts = explode(Zend_Mime::LINEEND, $header);
     if (count($parts) > 0) {
         for ($i = 0; $i < count($parts); $i++) {
             if (preg_match('/(=?[a-z0-9-_]+\\?[q|b]{1}\\?)/i', $parts[$i], $matches)) {
                 $dce = sprintf("=?%s", $matches[0]);
                 // Check that Delimiter, Charset, Encoding are at the front of the string
                 if (substr(trim($parts[$i]), 0, strlen($dce)) != $dce) {
                     $this->fail(sprintf("Header-Part '%s' in line '%d' has missing or malformated delimiter, charset, encoding information.", $parts[$i], $i + 1));
                 }
                 // check that the encoded word is not too long.);
                 // this is only some kind of suggestion by the standard, in PHP its hard to hold it, so we do not enforce it here.
                 /*if(strlen($parts[$i]) > 75) {
                       $this->fail(sprintf(
                           "Each encoded-word is only allowed to be 75 chars long, but line %d is %s chars long: %s",
                           $i+1,
                           strlen($parts[$i]),
                           $parts[$i]
                       ));
                   }*/
                 // Check that the end-delmiter ?= is correctly placed
                 if (substr(trim($parts[$i]), -2, 2) != "?=") {
                     $this->fail(sprintf("Lines with an encoded-word have to end in ?=, but line %d does not: %s", $i + 1, substr(trim($parts[$i]), -2, 2)));
                 }
                 // Check that only one encoded-word can be found per line.
                 if (substr_count($parts[$i], "=?") != 1) {
                     $this->fail(sprintf("Only one encoded-word is allowed per line in the header. It seems line %d contains more: %s", $i + 1, $parts[$i]));
                 }
                 // Check that the encoded-text only contains US-ASCII chars, and no space
                 $encodedText = substr(trim($parts[$i]), strlen($dce), -2);
                 if (preg_match('/([\\s]+)/', $encodedText)) {
                     $this->fail(sprintf("No whitespace characters allowed in encoded-text of line %d: %s", $i + 1, $parts[$i]));
                 }
                 for ($i = 0; $i < strlen($encodedText); $i++) {
                     if (ord($encodedText[$i]) > 127) {
                         $this->fail(sprintf("No non US-ASCII characters allowed, but line %d has them: %s", $i + 1, $parts[$i]));
                     }
                 }
             } else {
                 if (Zend_Mime::isPrintable($parts[$i]) == false) {
                     $this->fail(sprintf("Encoded-word in line %d contains non printable characters.", $i + 1));
                 }
             }
         }
     }
 }
開發者ID:jsnshrmn,項目名稱:Suma,代碼行數:54,代碼來源:MailTest.php

示例9: testPrintable

 public function testPrintable()
 {
     // check if isPrintable works right.
     $this->assertFalse(Zend_Mime::isPrintable('Test with special chars: дьяц÷'));
     $this->assertTrue(Zend_Mime::isPrintable('Test without special chars'));
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:6,代碼來源:MimeTest.php


注:本文中的Zend_Mime::isPrintable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。