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

Breadcrumb

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

function StringInputStream::replaceLinefeeds

Replace linefeed characters according to the spec.

1 call to StringInputStream::replaceLinefeeds()
StringInputStream::__construct in vendor/masterminds/html5/src/HTML5/Parser/StringInputStream.php
Create a new InputStream wrapper.

File

vendor/masterminds/html5/src/HTML5/Parser/StringInputStream.php, line 102

Class

StringInputStream

Namespace

Masterminds\HTML5\Parser

Code

protected function replaceLinefeeds($data) {
    
    /*
     * U+000D CARRIAGE RETURN (CR) characters and U+000A LINE FEED (LF) characters are treated specially.
     * Any CR characters that are followed by LF characters must be removed, and any CR characters not
     * followed by LF characters must be converted to LF characters. Thus, newlines in HTML DOMs are
     * represented by LF characters, and there are never any CR characters in the input to the tokenization
     * stage.
     */
    $crlfTable = array(
        "\x00" => "�",
        "\r\n" => "\n",
        "\r" => "\n",
    );
    return strtr($data, $crlfTable);
}

API Navigation

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