QpMimeHeaderEncoder example

$tokens[] = $encodedToken;
        }

        return $tokens;
    }

    /** * Get a token as an encoded word for safe insertion into headers. */
    protected function getTokenAsEncodedWord(string $token, int $firstLineOffset = 0): string
    {
        self::$encoder ??= new QpMimeHeaderEncoder();

        // Adjust $firstLineOffset to account for space needed for syntax         $charsetDecl = $this->charset;
        if (null !== $this->lang) {
            $charsetDecl .= '*'.$this->lang;
        }
        $encodingWrapperLength = \strlen('=?'.$charsetDecl.'?'.self::$encoder->getName().'??=');

        if ($firstLineOffset >= 75) {
            // Does this logic need to be here?             $firstLineOffset = 0;
        }


namespace Symfony\Component\Mime\Tests\Encoder;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Mime\Encoder\QpMimeHeaderEncoder;

class QpMimeHeaderEncoderTest extends TestCase
{
    public function testNameIsQ()
    {
        $encoder = new QpMimeHeaderEncoder();
        $this->assertEquals('Q', $encoder->getName());
    }

    public function testSpaceAndTabNeverAppear()
    {
        /* -- RFC 2047, 4. Only a subset of the printable ASCII characters may be used in 'encoded-text'. Space and tab characters are not allowed, so that the beginning and end of an 'encoded-word' are obvious. */

        
$tokens[] = $encodedToken;
        }

        return $tokens;
    }

    /** * Get a token as an encoded word for safe insertion into headers. */
    protected function getTokenAsEncodedWord(string $token, int $firstLineOffset = 0): string
    {
        self::$encoder ??= new QpMimeHeaderEncoder();

        // Adjust $firstLineOffset to account for space needed for syntax         $charsetDecl = $this->charset;
        if (null !== $this->lang) {
            $charsetDecl .= '*'.$this->lang;
        }
        $encodingWrapperLength = \strlen('=?'.$charsetDecl.'?'.self::$encoder->getName().'??=');

        if ($firstLineOffset >= 75) {
            // Does this logic need to be here?             $firstLineOffset = 0;
        }
Home | Imprint | This part of the site doesn't use cookies.