ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
Symfony\Component\Yaml\Unescaper Class Reference

Unescaper encapsulates unescaping rules for single and double-quoted YAML strings. More...

+ Collaboration diagram for Symfony\Component\Yaml\Unescaper:

Public Member Functions

 unescapeSingleQuotedString ($value)
 Unescapes a single quoted string. More...
 
 unescapeDoubleQuotedString ($value)
 Unescapes a double quoted string. More...
 

Data Fields

const REGEX_ESCAPED_CHARACTER = '\\\\‍(x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8}|.)'
 Regex fragment that matches an escaped character in a double quoted string. More...
 

Private Member Functions

 unescapeCharacter ($value)
 Unescapes a character that was found in a double-quoted string. More...
 

Static Private Member Functions

static utf8chr ($c)
 Get the UTF-8 character for the given code point. More...
 

Detailed Description

Unescaper encapsulates unescaping rules for single and double-quoted YAML strings.

Author
Matthew Lewinski matth.nosp@m.ew@l.nosp@m.ewins.nosp@m.ki.o.nosp@m.rg

Definition at line 24 of file Unescaper.php.

Member Function Documentation

◆ unescapeCharacter()

Symfony\Component\Yaml\Unescaper::unescapeCharacter (   $value)
private

Unescapes a character that was found in a double-quoted string.

Parameters
string$valueAn escaped character
Returns
string The unescaped character

Definition at line 67 of file Unescaper.php.

68 {
69 switch ($value[1]) {
70 case '0':
71 return "\x0";
72 case 'a':
73 return "\x7";
74 case 'b':
75 return "\x8";
76 case 't':
77 return "\t";
78 case "\t":
79 return "\t";
80 case 'n':
81 return "\n";
82 case 'v':
83 return "\xB";
84 case 'f':
85 return "\xC";
86 case 'r':
87 return "\r";
88 case 'e':
89 return "\x1B";
90 case ' ':
91 return ' ';
92 case '"':
93 return '"';
94 case '/':
95 return '/';
96 case '\\':
97 return '\\';
98 case 'N':
99 // U+0085 NEXT LINE
100 return "\xC2\x85";
101 case '_':
102 // U+00A0 NO-BREAK SPACE
103 return "\xC2\xA0";
104 case 'L':
105 // U+2028 LINE SEPARATOR
106 return "\xE2\x80\xA8";
107 case 'P':
108 // U+2029 PARAGRAPH SEPARATOR
109 return "\xE2\x80\xA9";
110 case 'x':
111 return self::utf8chr(hexdec(substr($value, 2, 2)));
112 case 'u':
113 return self::utf8chr(hexdec(substr($value, 2, 4)));
114 case 'U':
115 return self::utf8chr(hexdec(substr($value, 2, 8)));
116 default:
117 throw new ParseException(sprintf('Found unknown escape character "%s".', $value));
118 }
119 }
sprintf('%.4f', $callTime)
static utf8chr($c)
Get the UTF-8 character for the given code point.
Definition: Unescaper.php:128

References sprintf, and Symfony\Component\Yaml\Unescaper\utf8chr().

Referenced by Symfony\Component\Yaml\Unescaper\unescapeDoubleQuotedString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unescapeDoubleQuotedString()

Symfony\Component\Yaml\Unescaper::unescapeDoubleQuotedString (   $value)

Unescapes a double quoted string.

Parameters
string$valueA double quoted string
Returns
string The unescaped string

Definition at line 50 of file Unescaper.php.

51 {
52 $callback = function ($match) {
53 return $this->unescapeCharacter($match[0]);
54 };
55
56 // evaluate the string
57 return preg_replace_callback('/'.self::REGEX_ESCAPED_CHARACTER.'/u', $callback, $value);
58 }
unescapeCharacter($value)
Unescapes a character that was found in a double-quoted string.
Definition: Unescaper.php:67

References Symfony\Component\Yaml\Unescaper\unescapeCharacter().

+ Here is the call graph for this function:

◆ unescapeSingleQuotedString()

Symfony\Component\Yaml\Unescaper::unescapeSingleQuotedString (   $value)

Unescapes a single quoted string.

Parameters
string$valueA single quoted string
Returns
string The unescaped string

Definition at line 38 of file Unescaper.php.

39 {
40 return str_replace('\'\'', '\'', $value);
41 }

◆ utf8chr()

static Symfony\Component\Yaml\Unescaper::utf8chr (   $c)
staticprivate

Get the UTF-8 character for the given code point.

Parameters
int$cThe unicode code point
Returns
string The corresponding UTF-8 character

Definition at line 128 of file Unescaper.php.

129 {
130 if (0x80 > $c %= 0x200000) {
131 return chr($c);
132 }
133 if (0x800 > $c) {
134 return chr(0xC0 | $c >> 6).chr(0x80 | $c & 0x3F);
135 }
136 if (0x10000 > $c) {
137 return chr(0xE0 | $c >> 12).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F);
138 }
139
140 return chr(0xF0 | $c >> 18).chr(0x80 | $c >> 12 & 0x3F).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F);
141 }

Referenced by Symfony\Component\Yaml\Unescaper\unescapeCharacter().

+ Here is the caller graph for this function:

Field Documentation

◆ REGEX_ESCAPED_CHARACTER

const Symfony\Component\Yaml\Unescaper::REGEX_ESCAPED_CHARACTER = '\\\\‍(x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8}|.)'

Regex fragment that matches an escaped character in a double quoted string.

Definition at line 29 of file Unescaper.php.


The documentation for this class was generated from the following file: