86     $this->_charset = $charset;
 
   87     if (isset($this->_encoder))
 
   89       $this->_encoder->charsetChanged($charset);
 
  111     $this->_lang = 
$lang;
 
  129     $this->_encoder = $encoder;
 
  158     $this->_lineLength = $lineLength;
 
  201     $this->_name = $name;
 
  210     $this->_specials = array(
 
  211       '(', 
')', 
'<', 
'>', 
'[', 
']',
 
  212       ':', 
';', 
'@', 
',', 
'.', 
'"' 
  218     $this->_grammar[
'NO-WS-CTL'] = 
'[\x01-\x08\x0B\x0C\x0E-\x19\x7F]';
 
  219     $this->_grammar[
'WSP'] = 
'[ \t]';
 
  220     $this->_grammar[
'CRLF'] = 
'(?:\r\n)';
 
  221     $this->_grammar[
'FWS'] = 
'(?:(?:' . $this->_grammar[
'WSP'] . 
'*' .
 
  222         $this->_grammar[
'CRLF'] . 
')?' . $this->_grammar[
'WSP'] . 
')';
 
  223     $this->_grammar[
'text'] = 
'[\x00-\x08\x0B\x0C\x0E-\x7F]';
 
  224     $this->_grammar[
'quoted-pair'] = 
'(?:\\\\' . $this->_grammar[
'text'] . 
')';
 
  225     $this->_grammar[
'ctext'] = 
'(?:' . $this->_grammar[
'NO-WS-CTL'] .
 
  226         '|[\x21-\x27\x2A-\x5B\x5D-\x7E])';
 
  228     $this->_grammar[
'ccontent'] = 
'(?:' . $this->_grammar[
'ctext'] . 
'|' .
 
  229         $this->_grammar[
'quoted-pair'] . 
'|(?1))';
 
  230     $this->_grammar[
'comment'] = 
'(\((?:' . $this->_grammar[
'FWS'] . 
'|' .
 
  231         $this->_grammar[
'ccontent']. 
')*' . $this->_grammar[
'FWS'] . 
'?\))';
 
  232     $this->_grammar[
'CFWS'] = 
'(?:(?:' . $this->_grammar[
'FWS'] . 
'?' .
 
  233         $this->_grammar[
'comment'] . 
')*(?:(?:' . $this->_grammar[
'FWS'] . 
'?' .
 
  234         $this->_grammar[
'comment'] . 
')|' . $this->_grammar[
'FWS'] . 
'))';
 
  235     $this->_grammar[
'qtext'] = 
'(?:' . $this->_grammar[
'NO-WS-CTL'] .
 
  236         '|[\x21\x23-\x5B\x5D-\x7E])';
 
  237     $this->_grammar[
'qcontent'] = 
'(?:' . $this->_grammar[
'qtext'] . 
'|' .
 
  238         $this->_grammar[
'quoted-pair'] . 
')';
 
  239     $this->_grammar[
'quoted-string'] = 
'(?:' . $this->_grammar[
'CFWS'] . 
'?"' .
 
  240         '(' . $this->_grammar[
'FWS'] . 
'?' . $this->_grammar[
'qcontent'] . 
')*' .
 
  241         $this->_grammar[
'FWS'] . 
'?"' . $this->_grammar[
'CFWS'] . 
'?)';
 
  242     $this->_grammar[
'atext'] = 
'[a-zA-Z0-9!#\$%&\'\*\+\-\/=\?\^_`\{\}\|~]';
 
  243     $this->_grammar[
'atom'] = 
'(?:' . $this->_grammar[
'CFWS'] . 
'?' .
 
  244         $this->_grammar[
'atext'] . 
'+' . $this->_grammar[
'CFWS'] . 
'?)';
 
  245     $this->_grammar[
'dot-atom-text'] = 
'(?:' . $this->_grammar[
'atext'] . 
'+' .
 
  246         '(\.' . $this->_grammar[
'atext'] . 
'+)*)';
 
  247     $this->_grammar[
'dot-atom'] = 
'(?:' . $this->_grammar[
'CFWS'] . 
'?' .
 
  248         $this->_grammar[
'dot-atom-text'] . 
'+' . $this->_grammar[
'CFWS'] . 
'?)';
 
  249     $this->_grammar[
'word'] = 
'(?:' . $this->_grammar[
'atom'] . 
'|' .
 
  250         $this->_grammar[
'quoted-string'] . 
')';
 
  251     $this->_grammar[
'phrase'] = 
'(?:' . $this->_grammar[
'word'] . 
'+?)';
 
  252     $this->_grammar[
'no-fold-quote'] = 
'(?:"(?:' . $this->_grammar[
'qtext'] .
 
  253         '|' . $this->_grammar[
'quoted-pair'] . 
')*")';
 
  254     $this->_grammar[
'dtext'] = 
'(?:' . $this->_grammar[
'NO-WS-CTL'] .
 
  255         '|[\x21-\x5A\x5E-\x7E])';
 
  256     $this->_grammar[
'no-fold-literal'] = 
'(?:\[(?:' . $this->_grammar[
'dtext'] .
 
  257         '|' . $this->_grammar[
'quoted-pair'] . 
')*\])';
 
  260     $this->_grammar[
'id-left'] = 
'(?:' . $this->_grammar[
'dot-atom-text'] . 
'|' .
 
  261         $this->_grammar[
'no-fold-quote'] . 
')';
 
  262     $this->_grammar[
'id-right'] = 
'(?:' . $this->_grammar[
'dot-atom-text'] . 
'|' .
 
  263         $this->_grammar[
'no-fold-literal'] . 
')';
 
  266     $this->_grammar[
'local-part'] = 
'(?:' . $this->_grammar[
'dot-atom'] . 
'|' .
 
  267         $this->_grammar[
'quoted-string'] . 
')';
 
  268     $this->_grammar[
'dcontent'] = 
'(?:' . $this->_grammar[
'dtext'] . 
'|' .
 
  269         $this->_grammar[
'quoted-pair'] . 
')';
 
  270     $this->_grammar[
'domain-literal'] = 
'(?:' . $this->_grammar[
'CFWS'] . 
'?\[(' .
 
  271         $this->_grammar[
'FWS'] . 
'?' . $this->_grammar[
'dcontent'] . 
')*?' .
 
  272         $this->_grammar[
'FWS'] . 
'?\]' . $this->_grammar[
'CFWS'] . 
'?)';
 
  273     $this->_grammar[
'domain'] = 
'(?:' . $this->_grammar[
'dot-atom'] . 
'|' .
 
  274         $this->_grammar[
'domain-literal'] . 
')';
 
  275     $this->_grammar[
'addr-spec'] = 
'(?:' . $this->_grammar[
'local-part'] . 
'@' .
 
  276         $this->_grammar[
'domain'] . 
')';
 
  286     if (array_key_exists($name, $this->_grammar))
 
  288       return $this->_grammar[$name];
 
  293         "No such grammar '" . $name . 
"' defined." 
  309       array_merge(array(
'\\'), array_diff($this->_specials, $exclude), $include) as $char)
 
  329     $phraseStr = $string;
 
  331     if (!preg_match(
'/^' . $this->_grammar[
'phrase'] . 
'$/D', $phraseStr))
 
  335       if (preg_match(
'/^' . $this->_grammar[
'text'] . 
'*$/D', $phraseStr))
 
  338           $phraseStr, array(
'"'), $this->_specials
 
  340         $phraseStr = 
'"' . $phraseStr . 
'"';
 
  353         $phraseStr = $this->
encodeWords($header, $string, $usedLength);
 
  373     foreach ($tokens as 
$token)
 
  379         $firstChar = substr($token, 0, 1);
 
  384             $value .= $firstChar;
 
  385             $token = substr($token, 1);
 
  388         if (-1 == $usedLength)
 
  390           $usedLength = strlen($header->
getFieldName() . 
': ') + strlen($value);
 
  394         $header->setMaxLineLength(76); 
 
  412     return preg_match(
'~[\x00-\x08\x10-\x19\x7F-\xFF\r\n]~', 
$token);
 
  426     foreach (preg_split(
'~(?=[\t ])~', $string) as 
$token)
 
  434         if (strlen($encodedToken) > 0)
 
  436           $tokens[] = $encodedToken;
 
  442     if (strlen($encodedToken))
 
  444       $tokens[] = $encodedToken;
 
  460     if (isset($this->_lang))
 
  464     $encodingWrapperLength = strlen(
 
  465       '=?' . $charsetDecl . 
'?' . $this->_encoder->getName() . 
'??=' 
  468     if ($firstLineOffset >= 75) 
 
  470       $firstLineOffset = 0;
 
  473     $encodedTextLines = explode(
"\r\n",
 
  474       $this->_encoder->encodeString(
 
  475         $token, $firstLineOffset, 75 - $encodingWrapperLength
 
  479     foreach ($encodedTextLines as $lineNum => $line)
 
  481       $encodedTextLines[$lineNum] = 
'=?' . $charsetDecl .
 
  482         '?' . $this->_encoder->getName() .
 
  486     return implode(
"\r\n ", $encodedTextLines);
 
  497     return preg_split(
'~(\r\n)~', 
$token, -1, PREG_SPLIT_DELIM_CAPTURE);
 
  507     $this->_cachedValue = $value;
 
  543     if (is_null($string))
 
  551     foreach (preg_split(
'~(?=[ \t])~', $string) as 
$token)
 
  569     $headerLines = array();
 
  570     $headerLines[] = $this->_name . 
': ';
 
  571     $currentLine =& $headerLines[$lineCount++];
 
  578         (
$i > 0 && strlen($currentLine . 
$token) > $this->_lineLength)
 
  579         && 0 < strlen($currentLine))
 
  582         $currentLine =& $headerLines[$lineCount++];
 
  586       if (
"\r\n" != $token)
 
  593     return implode(
"\r\n", $headerLines) . 
"\r\n";