function QpEncoder::encodeString
Takes an unencoded string and produces a QP encoded string from it.
QP encoded strings have a maximum line length of 76 characters. If the first line needs to be shorter, indicate the difference with $firstLineOffset.
Overrides EncoderInterface::encodeString
2 calls to QpEncoder::encodeString()
- QpMimeHeaderEncoder::encodeString in vendor/
symfony/ mime/ Encoder/ QpMimeHeaderEncoder.php - Takes an unencoded string and produces a QP encoded string from it.
- QpMimeHeaderEncoder::encodeString in vendor/
symfony/ mime/ Encoder/ QpMimeHeaderEncoder.php - Takes an unencoded string and produces a QP encoded string from it.
1 method overrides QpEncoder::encodeString()
- QpMimeHeaderEncoder::encodeString in vendor/
symfony/ mime/ Encoder/ QpMimeHeaderEncoder.php - Takes an unencoded string and produces a QP encoded string from it.
File
-
vendor/
symfony/ mime/ Encoder/ QpEncoder.php, line 115
Class
- QpEncoder
- @author Chris Corbyn
Namespace
Symfony\Component\Mime\EncoderCode
public function encodeString(string $string, ?string $charset = 'utf-8', int $firstLineOffset = 0, int $maxLineLength = 0) : string {
if ($maxLineLength > 76 || $maxLineLength <= 0) {
$maxLineLength = 76;
}
$thisLineLength = $maxLineLength - $firstLineOffset;
$lines = [];
$lNo = 0;
$lines[$lNo] = '';
$currentLine =& $lines[$lNo++];
$size = $lineLen = 0;
$charStream = new CharacterStream($string, $charset);
// Fetching more than 4 chars at one is slower, as is fetching fewer bytes
// Conveniently 4 chars is the UTF-8 safe number since UTF-8 has up to 6
// bytes per char and (6 * 4 * 3 = 72 chars per line) * =NN is 3 bytes
while (null !== ($bytes = $charStream->readBytes(4))) {
$enc = $this->encodeByteSequence($bytes, $size);
$i = strpos($enc, '=0D=0A');
$newLineLength = $lineLen + (false === $i ? $size : $i);
if ($currentLine && $newLineLength >= $thisLineLength) {
$lines[$lNo] = '';
$currentLine =& $lines[$lNo++];
$thisLineLength = $maxLineLength;
$lineLen = 0;
}
$currentLine .= $enc;
if (false === $i) {
$lineLen += $size;
}
else {
// 6 is the length of '=0D=0A'.
$lineLen = $size - strrpos($enc, '=0D=0A') - 6;
}
}
return $this->standardize(implode("=\r\n", $lines));
}