/** * 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; } }
public function testBase64() { $content = str_repeat("И™ѓњ)И™ѓњ)И™ѓ", 4); $encoded = Zend_Mime::encodeBase64($content); $this->assertEquals($content, base64_decode($encoded)); }
public function testBase64() { $content = str_repeat("\x88\xAA\xAF\xBF\x29\x88\xAA\xAF\xBF\x29\x88\xAA\xAF", 4); $encoded = Zend_Mime::encodeBase64($content); $this->assertEquals($content, base64_decode($encoded)); }