original_string: public static function encodeQuotedPrintableHeader($str, $charset,
          $lineLength = self::LINELENGTH,
          $lineEnd = self::LINEEND)
      {
          // Reduce line-length by the length of the required delimiter, charsets and encoding
          $prefix = sprintf('=?%s?Q?', $charset);
          $lineLength = $lineLength-strlen($prefix)-3;
  
          $str = self::_encodeQuotedPrintable($str);
  
          // Mail-Header required chars have to be encoded also:
          $str = str_replace(array('?', ' ', '_'), array('=3F', '=20', '=5F'), $str);
  
          // initialize first line, we need it anyways
          $lines = array(0 => "");
  
          // Split encoded text into separate lines
          $tmp = "";
          while(strlen($str) > 0) {
              $currentLine = max(count($lines)-1, 0);
              $token       = self::getNextQuotedPrintableToken($str);
              $str         = substr($str, strlen($token));
  
              $tmp .= $token;
              if($token == '=20') {
                  // only if we have a single char token or space, we can append the
                  // tempstring it to the current line or start a new line if necessary.
                  if(strlen($lines[$currentLine].$tmp) > $lineLength) {
                      $lines[$currentLine+1] = $tmp;
                  } else {
                      $lines[$currentLine] .= $tmp;
                  }
                  $tmp = "";
              }
              // don't forget to append the rest to the last line
              if(strlen($str) == 0) {
                  $lines[$currentLine] .= $tmp;
              }
          }
  
          // assemble the lines together by pre- and appending delimiters, charset, encoding.
          for($i = 0; $i < count($lines); $i++) {
              $lines[$i] = " ".$prefix.$lines[$i]."?=";
          }
          $str = trim(implode($lineEnd, $lines));
          return $str;
      }
code: public static function encodeQuotedPrintableHeader($str, $charset,
          $lineLength = self::LINELENGTH,
          $lineEnd = self::LINEEND)
      {
          // Reduce line-length by the length of the required delimiter, charsets and encoding
          $prefix = sprintf('=?%s?Q?', $charset);
          $lineLength = $lineLength-strlen($prefix)-3;
  
          $str = self::_encodeQuotedPrintable($str);
  
          // Mail-Header required chars have to be encoded also:
          $str = str_replace(array('?', ' ', '_'), array('=3F', '=20', '=5F'), $str);
  
          // initialize first line, we need it anyways
          $lines = array(0 => "");
  
          // Split encoded text into separate lines
          $tmp = "";
          while(strlen($str) > 0) {
              $currentLine = max(count($lines)-1, 0);
              $token       = self::getNextQuotedPrintableToken($str);
              $str         = substr($str, strlen($token));
  
              $tmp .= $token;
              if($token == '=20') {
                  // only if we have a single char token or space, we can append the
                  // tempstring it to the current line or start a new line if necessary.
                  if(strlen($lines[$currentLine].$tmp) > $lineLength) {
                      $lines[$currentLine+1] = $tmp;
                  } else {
                      $lines[$currentLine] .= $tmp;
                  }
                  $tmp = "";
              }
              // don't forget to append the rest to the last line
              if(strlen($str) == 0) {
                  $lines[$currentLine] .= $tmp;
              }
          }
  
          // assemble the lines together by pre- and appending delimiters, charset, encoding.
          for($i = 0; $i < count($lines); $i++) {
              $lines[$i] = " ".$prefix.$lines[$i]."?=";
          }
          $str = trim(implode($lineEnd, $lines));
          return $str;
      }
code_tokens: public static function encodeQuotedPrintableHeader ( $ str , $ charset , $ lineLength = self :: LINELENGTH , $ lineEnd = self :: LINEEND ) { // Reduce line-length by the length of the required delimiter, charsets and encoding $ prefix = sprintf ( '=?%s?Q?' , $ charset ) ; $ lineLength = $ lineLength - strlen ( $ prefix ) - 3 ; $ str = self :: _encodeQuotedPrintable ( $ str ) ; // Mail-Header required chars have to be encoded also: $ str = str_replace ( array ( '?' , ' ' , '_' ) , array ( '=3F' , '=20' , '=5F' ) , $ str ) ; // initialize first line, we need it anyways $ lines = array ( 0 => "" ) ; // Split encoded text into separate lines $ tmp = "" ; while ( strlen ( $ str ) > 0 ) { $ currentLine = max ( count ( $ lines ) - 1 , 0 ) ; $ token = self :: getNextQuotedPrintableToken ( $ str ) ; $ str = substr ( $ str , strlen ( $ token ) ) ; $ tmp .= $ token ; if ( $ token == '=20' ) { // only if we have a single char token or space, we can append the // tempstring it to the current line or start a new line if necessary. if ( strlen ( $ lines [ $ currentLine ] . $ tmp ) > $ lineLength ) { $ lines [ $ currentLine + 1 ] = $ tmp ; } else { $ lines [ $ currentLine ] .= $ tmp ; } $ tmp = "" ; } // don't forget to append the rest to the last line if ( strlen ( $ str ) == 0 ) { $ lines [ $ currentLine ] .= $ tmp ; } } // assemble the lines together by pre- and appending delimiters, charset, encoding. for ( $ i = 0 ; $ i < count ( $ lines ) ; $ i ++ ) { $ lines [ $ i ] = " " . $ prefix . $ lines [ $ i ] . "?=" ; } $ str = trim ( implode ( $ lineEnd , $ lines ) ) ; return $ str ; }
docstring: Encode a given string with the QUOTED_PRINTABLE mechanism for Mail Headers.
  
  Mail headers depend on an extended quoted printable algorithm otherwise
  a range of bugs can occur.
  
  @param string $str
  @param string $charset
  @param int $lineLength Defaults to {@link LINELENGTH}
  @param int $lineEnd Defaults to {@link LINEEND}
  @return string
docstring_tokens: Encode a given string with the QUOTED_PRINTABLE mechanism for Mail Headers .