Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. AbstractHeader.php

function AbstractHeader::getTokenAsEncodedWord

Get a token as an encoded word for safe insertion into headers.

2 calls to AbstractHeader::getTokenAsEncodedWord()
AbstractHeader::encodeWords in vendor/symfony/mime/Header/AbstractHeader.php
Encode needed word tokens within a string of input.
ParameterizedHeader::createParameter in vendor/symfony/mime/Header/ParameterizedHeader.php
Render an RFC 2047 compliant header parameter from the $name and $value.

File

vendor/symfony/mime/Header/AbstractHeader.php, line 203

Class

AbstractHeader
An abstract base MIME Header.

Namespace

Symfony\Component\Mime\Header

Code

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;
    }
    $encodedTextLines = explode("\r\n", self::$encoder->encodeString($token, $this->charset, $firstLineOffset, 75 - $encodingWrapperLength));
    if ('iso-2022-jp' !== strtolower($this->charset)) {
        // special encoding for iso-2022-jp using mb_encode_mimeheader
        foreach ($encodedTextLines as $lineNum => $line) {
            $encodedTextLines[$lineNum] = '=?' . $charsetDecl . '?' . self::$encoder->getName() . '?' . $line . '?=';
        }
    }
    return implode("\r\n ", $encodedTextLines);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal