/** * Get a token as an encoded word for safe insertion into headers. * @param string $token to encode * @param int $firstLineOffset, optional * @return string */ protected function getTokenAsEncodedWord($token, $firstLineOffset = 0) { //Adjust $firstLineOffset to account for space needed for syntax $charsetDecl = $this->_charset; if (isset($this->_lang)) { $charsetDecl .= '*' . $this->_lang; } $encodingWrapperLength = strlen( '=?' . $charsetDecl . '?' . $this->_encoder->getName() . '??=' ); if ($firstLineOffset >= 75) //Does this logic need to be here? { $firstLineOffset = 0; } $encodedTextLines = explode("\r\n", $this->_encoder->encodeString( $token, $firstLineOffset, 75 - $encodingWrapperLength ) ); foreach ($encodedTextLines as $lineNum => $line) { $encodedTextLines[$lineNum] = '=?' . $charsetDecl . '?' . $this->_encoder->getName() . '?' . $line . '?='; } return implode("\r\n ", $encodedTextLines); }
/** * Get a token as an encoded word for safe insertion into headers. * * @param string $token token to encode * @param int $firstLineOffset optional * * @return string */ protected function getTokenAsEncodedWord($token, $firstLineOffset = 0) { // Adjust $firstLineOffset to account for space needed for syntax $charsetDecl = $this->charset; if (isset($this->lang)) { $charsetDecl .= '*' . $this->lang; } $encodingWrapperLength = strlen('=?' . $charsetDecl . '?' . $this->encoder->getName() . '??='); if ($firstLineOffset >= 75) { //Does this logic need to be here? $firstLineOffset = 0; } $encodedTextLines = explode("\r\n", $this->encoder->encodeString($token, $firstLineOffset, 75 - $encodingWrapperLength, $this->charset)); if (strtolower($this->charset) !== 'iso-2022-jp') { // special encoding for iso-2022-jp using mb_encode_mimeheader foreach ($encodedTextLines as $lineNum => $line) { $encodedTextLines[$lineNum] = '=?' . $charsetDecl . '?' . $this->encoder->getName() . '?' . $line . '?='; } } return implode("\r\n ", $encodedTextLines); }