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

Breadcrumb

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

function AbstractHeader::encodeWords

Encode needed word tokens within a string of input.

2 calls to AbstractHeader::encodeWords()
AbstractHeader::createPhrase in vendor/symfony/mime/Header/AbstractHeader.php
Produces a compliant, formatted RFC 2822 'phrase' based on the string given.
UnstructuredHeader::getBodyAsString in vendor/symfony/mime/Header/UnstructuredHeader.php
Get the value of this header prepared for rendering.

File

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

Class

AbstractHeader
An abstract base MIME Header.

Namespace

Symfony\Component\Mime\Header

Code

protected function encodeWords(HeaderInterface $header, string $input, int $usedLength = -1) : string {
    $value = '';
    $tokens = $this->getEncodableWordTokens($input);
    foreach ($tokens as $token) {
        // See RFC 2822, Sect 2.2 (really 2.2 ??)
        if ($this->tokenNeedsEncoding($token)) {
            // Don't encode starting WSP
            $firstChar = substr($token, 0, 1);
            switch ($firstChar) {
                case ' ':
                case "\t":
                    $value .= $firstChar;
                    $token = substr($token, 1);
            }
            if (-1 == $usedLength) {
                $usedLength = \strlen($header->getName() . ': ') + \strlen($value);
            }
            $value .= $this->getTokenAsEncodedWord($token, $usedLength);
        }
        else {
            $value .= $token;
        }
    }
    return $value;
}

API Navigation

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