You are here

private function TokenizerEscaping::replaceUnicodeSequences in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/css-selector/Parser/Tokenizer/TokenizerEscaping.php \Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping::replaceUnicodeSequences()

Parameters

string $value:

Return value

string

1 call to TokenizerEscaping::replaceUnicodeSequences()
TokenizerEscaping::escapeUnicode in vendor/symfony/css-selector/Parser/Tokenizer/TokenizerEscaping.php

File

vendor/symfony/css-selector/Parser/Tokenizer/TokenizerEscaping.php, line 66

Class

TokenizerEscaping
CSS selector tokenizer escaping applier.

Namespace

Symfony\Component\CssSelector\Parser\Tokenizer

Code

private function replaceUnicodeSequences($value) {
  return preg_replace_callback($this->patterns
    ->getUnicodeEscapePattern(), function ($match) {
    $c = hexdec($match[1]);
    if (0x80 > ($c %= 0x200000)) {
      return chr($c);
    }
    if (0x800 > $c) {
      return chr(0xc0 | $c >> 6) . chr(0x80 | $c & 0x3f);
    }
    if (0x10000 > $c) {
      return chr(0xe0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3f) . chr(0x80 | $c & 0x3f);
    }
  }, $value);
}