41 $this->_canonical = $canonical;
53 public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0)
55 if ($this->_canonical) {
59 return $this->_safeWordWrap($string, $maxLineLength,
"\r\n");
73 while (
false !== $bytes = $os->
read(8192)) {
74 $toencode = $leftOver.$bytes;
75 if ($this->_canonical) {
78 $wrapped = $this->_safeWordWrap($toencode, $maxLineLength,
"\r\n");
79 $lastLinePos = strrpos($wrapped,
"\r\n");
80 $leftOver = substr($wrapped, $lastLinePos);
81 $wrapped = substr($wrapped, 0, $lastLinePos);
85 if (strlen($leftOver)) {
86 $is->
write($leftOver);
122 $originalLines = explode($le, $string);
127 foreach ($originalLines as $originalLine) {
129 $currentLine = &$lines[$lineCount++];
132 $chunks = preg_split(
'/(?<=\s)/', $originalLine);
134 foreach ($chunks as $chunk) {
135 if (0 != strlen($currentLine)
136 && strlen($currentLine.$chunk) > $length) {
138 $currentLine = &$lines[$lineCount++];
140 $currentLine .= $chunk;
144 return implode(
"\r\n", $lines);
157 array(
"\r\n",
"\r",
"\n"),
158 array(
"\n",
"\n",
"\r\n"),