From d661c2a2f654ba8f2bddeeac0b8a80dcd59649ab Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 5 May 2012 08:28:23 +0200 Subject: [PATCH] switched to use mbstring whenever possible instead of iconv (because of issues with iconv and Japanese -- thanks @ganchiku for the tip) --- CHANGELOG | 1 + lib/Twig/Extension/Core.php | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 2354fd0..659cb71 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ * 1.8.0 (2012-05-08) + * switched to use mbstring whenever possible instead of iconv * enforced interface when adding tests, filters, functions, and node visitors from extensions * fixed a side-effect of the date filter where the timezone might be changed * simplified usage of the autoescape tag; the only (optional) argument is now the escaping strategy or false (with a BC layer) diff --git a/lib/Twig/Extension/Core.php b/lib/Twig/Extension/Core.php index 37415ae..e9ce03f 100644 --- a/lib/Twig/Extension/Core.php +++ b/lib/Twig/Extension/Core.php @@ -825,15 +825,15 @@ function twig_escape_filter_is_safe(Twig_Node $filterArgs) return array('html'); } -if (function_exists('iconv')) { +if (function_exists('mb_convert_encoding')) { function twig_convert_encoding($string, $to, $from) { - return iconv($from, $to, $string); + return mb_convert_encoding($string, $to, $from); } -} elseif (function_exists('mb_convert_encoding')) { +} elseif (function_exists('iconv')) { function twig_convert_encoding($string, $to, $from) { - return mb_convert_encoding($string, $to, $from); + return iconv($from, $to, $string); } } else { function twig_convert_encoding($string, $to, $from) -- 1.7.2.5