You are here

public function Unescaper::unescapeCharacter in Translation template extractor 6.3

Same name and namespace in other branches
  1. 7.3 vendor/Symfony/Component/Yaml/Unescaper.php \Symfony\Component\Yaml\Unescaper::unescapeCharacter()
  2. 7.2 vendor/Symfony/Component/Yaml/Unescaper.php \Symfony\Component\Yaml\Unescaper::unescapeCharacter()

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

Parameters

string $value An escaped character:

Return value

string The unescaped character

File

vendor/Symfony/Component/Yaml/Unescaper.php, line 66

Class

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

Namespace

Symfony\Component\Yaml

Code

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':

      // U+0085 NEXT LINE
      return $this
        ->convertEncoding("", self::ENCODING, 'UCS-2BE');
    case '_':

      // U+00A0 NO-BREAK SPACE
      return $this
        ->convertEncoding("", self::ENCODING, 'UCS-2BE');
    case 'L':

      // U+2028 LINE SEPARATOR
      return $this
        ->convertEncoding(" (", self::ENCODING, 'UCS-2BE');
    case 'P':

      // U+2029 PARAGRAPH SEPARATOR
      return $this
        ->convertEncoding(" )", self::ENCODING, 'UCS-2BE');
    case 'x':
      $char = pack('n', hexdec(substr($value, 2, 2)));
      return $this
        ->convertEncoding($char, self::ENCODING, 'UCS-2BE');
    case 'u':
      $char = pack('n', hexdec(substr($value, 2, 4)));
      return $this
        ->convertEncoding($char, self::ENCODING, 'UCS-2BE');
    case 'U':
      $char = pack('N', hexdec(substr($value, 2, 8)));
      return $this
        ->convertEncoding($char, self::ENCODING, 'UCS-4BE');
  }
}