You are here

protected function StringInputStream::replaceLinefeeds in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/masterminds/html5/src/HTML5/Parser/StringInputStream.php \Masterminds\HTML5\Parser\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 95

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(
    "\0" => "�",
    "\r\n" => "\n",
    "\r" => "\n",
  );
  return strtr($data, $crlfTable);
}