Browse Source

merged branch schmittjoh/mbFix (PR #2194)

Commits
-------

8e2cbe6 fixes usage of mb_*

Discussion
----------

Fixes usage of mb_strlen

---------------------------------------------------------------------------

by Seldaek at 2011/09/16 05:33:45 -0700

This will fail if the mbstring ext isn't enabled, you should still test for the mb_ function first.
Fabien Potencier 13 years ago
parent
commit
607337b022
1 changed files with 5 additions and 1 deletions
  1. 5 1
      src/Symfony/Component/Console/Application.php

+ 5 - 1
src/Symfony/Component/Console/Application.php

@@ -720,7 +720,11 @@ class Application
     {
         $strlen = function ($string)
         {
-            return function_exists('mb_strlen') ? mb_strlen($string, mb_detect_encoding($string)) : strlen($string);
+            if (false === $encoding = mb_detect_encoding($string)) {
+                return strlen($string);
+            }
+
+            return function_exists('mb_strlen') ? mb_strlen($string, $encoding) : strlen($string);
         };
 
         do {