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

Breadcrumb

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

function Scanner::replaceLinefeeds

Replace linefeed characters according to the spec.

Parameters

$data:

Return value

string

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

File

vendor/masterminds/html5/src/HTML5/Parser/Scanner.php, line 336

Class

Scanner
The scanner scans over a given data input to react appropriately to characters.

Namespace

Masterminds\HTML5\Parser

Code

private 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