]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Apply utf8_encode only on unrecognized encoded string
authorYmage <heltem+github@o2php.com>
Thu, 7 Apr 2016 20:35:37 +0000 (22:35 +0200)
committerYmage <heltem+github@o2php.com>
Thu, 7 Apr 2016 20:35:37 +0000 (22:35 +0200)
inc/poche/Tools.class.php

index 3f68cff5e36a23efc446471ca8928944a1ad754b..2ee86c74e7ccb5823bfd4663454ba3ca90f8eab0 100755 (executable)
@@ -237,18 +237,25 @@ final class Tools
      *
      * @param $data
      */
-    public static function utf8ize($data) 
+    public static function utf8ize($data)
     {
-        if (is_array($data)) 
+       if (is_array($data))
         {
-            foreach ($data as $k => $v) 
+            foreach ($data as $k => $v)
             {
                 $data[$k] = self::utf8ize($v);
             }
         }
-        else if (is_string ($data)) 
+        else if (is_string ($data))
         {
-            return utf8_encode($data);
+            if ('' == mb_detect_encoding($data))
+            {
+                return utf8_encode($data);
+            }
+            else
+            {
+                return $data;
+            }
         }
         return $data;
     }