Unescaper.php in Loft Data Grids 6.2
File
vendor/symfony/yaml/Symfony/Component/Yaml/Unescaper.php
View source
<?php
namespace Symfony\Component\Yaml;
class Unescaper {
const ENCODING = 'UTF-8';
const REGEX_ESCAPED_CHARACTER = "\\\\([0abt\tnvfre \\\"\\/\\\\N_LP]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})";
public function unescapeSingleQuotedString($value) {
return str_replace('\'\'', '\'', $value);
}
public function unescapeDoubleQuotedString($value) {
$self = $this;
$callback = function ($match) use ($self) {
return $self
->unescapeCharacter($match[0]);
};
return preg_replace_callback('/' . self::REGEX_ESCAPED_CHARACTER . '/u', $callback, $value);
}
public function unescapeCharacter($value) {
switch ($value[1]) {
case '0':
return "\0";
case 'a':
return "\7";
case 'b':
return "\10";
case 't':
return "\t";
case "\t":
return "\t";
case 'n':
return "\n";
case 'v':
return "\v";
case 'f':
return "\f";
case 'r':
return "\r";
case 'e':
return "\33";
case ' ':
return ' ';
case '"':
return '"';
case '/':
return '/';
case '\\':
return '\\';
case 'N':
return "
";
case '_':
return " ";
case 'L':
return "
";
case 'P':
return "
";
case 'x':
return self::utf8chr(hexdec(substr($value, 2, 2)));
case 'u':
return self::utf8chr(hexdec(substr($value, 2, 4)));
case 'U':
return self::utf8chr(hexdec(substr($value, 2, 8)));
}
}
private static function utf8chr($c) {
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);
}
return chr(0xf0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3f) . chr(0x80 | $c >> 6 & 0x3f) . chr(0x80 | $c & 0x3f);
}
}
Classes
Name |
Description |
Unescaper |
Unescaper encapsulates unescaping rules for single and double-quoted
YAML strings. |