diff --git a/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php b/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php index ec8189b64b..4e72c1887f 100644 --- a/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php @@ -167,6 +167,9 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface */ protected function utf8Encode($s) { + if (!function_exists('iconv')) { + throw new \RuntimeException('Unable to convert a non-UTF-8 string to UTF-8: required function iconv() does not exist. You should install ext-iconv or symfony/polyfill-iconv.'); + } if (false !== $c = @iconv($this->charset, 'UTF-8', $s)) { return $c; } diff --git a/src/Symfony/Component/VarDumper/composer.json b/src/Symfony/Component/VarDumper/composer.json index 8213966c5a..5d0ca61a49 100644 --- a/src/Symfony/Component/VarDumper/composer.json +++ b/src/Symfony/Component/VarDumper/composer.json @@ -20,12 +20,14 @@ "symfony/polyfill-mbstring": "~1.0" }, "require-dev": { + "ext-iconv": "*", "twig/twig": "~1.20|~2.0" }, "conflict": { "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0" }, "suggest": { + "ext-iconv": "To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).", "ext-symfony_debug": "" }, "autoload": {