You are here

private function Unescaper::convertEncoding in Translation template extractor 7.3

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

Convert a string from one encoding to another.

Parameters

string $value The string to convert:

string $to The input encoding:

string $from The output encoding:

Return value

string The string with the new encoding

Throws

RuntimeException if no suitable encoding function is found (iconv or mbstring)

1 call to Unescaper::convertEncoding()
Unescaper::unescapeCharacter in vendor/Symfony/Component/Yaml/Unescaper.php
Unescapes a character that was found in a double-quoted string

File

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

Class

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

Namespace

Symfony\Component\Yaml

Code

private function convertEncoding($value, $to, $from) {
  if (function_exists('mb_convert_encoding')) {
    return mb_convert_encoding($value, $to, $from);
  }
  elseif (function_exists('iconv')) {
    return iconv($from, $to, $value);
  }
  throw new RuntimeException('No suitable convert encoding function (install the iconv or mbstring extension).');
}