当前位置: 首页>>代码示例>>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;未经允许,请勿转载。