24 public function encodeString(
string $string, ?
string $charset =
'utf-8',
int $firstLineOffset = 0,
int $maxLineLength = 0): string
29 $currentLine = &$lines[$lineCount++];
31 if (0 >= $maxLineLength) {
36 $thisLineLength = $maxLineLength - $firstLineOffset;
38 while (
null !== $char = $charStream->read(4)) {
39 $encodedChar = rawurlencode($char);
40 if (0 !== \strlen($currentLine) && \strlen($currentLine.$encodedChar) > $thisLineLength) {
42 $currentLine = &$lines[$lineCount++];
43 $thisLineLength = $maxLineLength;
45 $currentLine .= $encodedChar;
48 return implode(
"\r\n", $lines);