/** * Returns the ezcMailText part corresponding to the parsed message. * * @return ezcMailText */ public function finish() { $charset = "us-ascii"; // RFC 2822 default if (isset($this->headers['Content-Type'])) { preg_match('/\\s*charset\\s?=\\s?"?([^;"\\s]*);?/', $this->headers['Content-Type'], $parameters); if (count($parameters) > 0) { $charset = strtolower(trim($parameters[1], '"')); } } $encoding = strtolower($this->headers['Content-Transfer-Encoding']); if ($encoding == ezcMail::QUOTED_PRINTABLE) { $this->text = quoted_printable_decode($this->text); } else { if ($encoding == ezcMail::BASE64) { $this->text = base64_decode($this->text); } } $this->text = ezcMailCharsetConverter::convertToUTF8($this->text, $charset); $part = new ezcMailText($this->text, 'utf-8', ezcMail::EIGHT_BIT, $charset); $part->subType = $this->subType; $part->setHeaders($this->headers->getCaseSensitiveArray()); ezcMailPartParser::parsePartHeaders($this->headers, $part); $part->size = strlen($this->text); return $part; }
public function testQuotedPrintableEncode() { $reference = "Content-Type: text/plain; charset=iso-8859-1" . ezcMailTools::lineBreak() . "Content-Transfer-Encoding: quoted-printable" . ezcMailTools::lineBreak() . ezcMailTools::lineBreak() . "=E6=F8=E5=0A=F8=E6=E5"; $text = new ezcMailText("זרו\nרזו", "iso-8859-1", ezcMail::QUOTED_PRINTABLE); $this->assertEquals($reference, $text->generate()); }