/** * MIME-encode a value * * Performs quoted-printable encoding on a value, setting maximum * line-length to 998. * * @param string $value * @param string $encoding * @param int $lineLength maximum line-length, by default 998 * @return string Returns the mime encode value without the last line ending */ public static function mimeEncodeValue($value, $encoding, $lineLength = 998) { return Mime::encodeQuotedPrintableHeader($value, $encoding, $lineLength, Headers::EOL); }
/** * 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 (Mime\Mime::isPrintable($value) === false) { if ($this->getHeaderEncoding() === Mime\Mime::ENCODING_QUOTEDPRINTABLE) { $value = Mime\Mime::encodeQuotedPrintableHeader($value, $this->getCharset(), Mime\Mime::LINELENGTH, Mime\Mime::LINEEND); } else { $value = Mime\Mime::encodeBase64Header($value, $this->getCharset(), Mime\Mime::LINELENGTH, Mime\Mime::LINEEND); } } return $value; }
/** * @group ZF-1688 */ public function testLineLengthInQuotedPrintableHeaderEncoding() { $subject = "Alle meine Entchen schwimmen in dem See, schwimmen in dem See, Köpfchen in das Wasser, Schwänzchen in die Höh!"; $encoded = Mime\Mime::encodeQuotedPrintableHeader($subject, "UTF-8", 100); foreach(explode(Mime\Mime::LINEEND, $encoded) AS $line ) { if(strlen($line) > 100) { $this->fail("Line '".$line."' is ".strlen($line)." chars long, only 100 allowed."); } } $encoded = Mime\Mime::encodeQuotedPrintableHeader($subject, "UTF-8", 40); foreach(explode(Mime\Mime::LINEEND, $encoded) AS $line ) { if(strlen($line) > 40) { $this->fail("Line '".$line."' is ".strlen($line)." chars long, only 40 allowed."); } } }