diff options
author | Ymage <heltem+github@o2php.com> | 2016-04-07 22:35:37 +0200 |
---|---|---|
committer | Ymage <heltem+github@o2php.com> | 2016-04-07 22:35:37 +0200 |
commit | 7672a10776136842906e4f34e3ced0d7286f1c4a (patch) | |
tree | 97488ed99dbc286a6969d30bab9f78c4a5c5bf58 /inc/poche/Tools.class.php | |
parent | ccf59ac4fff1f66b312828cffbbb7090ef72d528 (diff) | |
download | wallabag-7672a10776136842906e4f34e3ced0d7286f1c4a.tar.gz wallabag-7672a10776136842906e4f34e3ced0d7286f1c4a.tar.zst wallabag-7672a10776136842906e4f34e3ced0d7286f1c4a.zip |
Apply utf8_encode only on unrecognized encoded string
Diffstat (limited to 'inc/poche/Tools.class.php')
-rwxr-xr-x | inc/poche/Tools.class.php | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index 3f68cff5..2ee86c74 100755 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php | |||
@@ -237,18 +237,25 @@ final class Tools | |||
237 | * | 237 | * |
238 | * @param $data | 238 | * @param $data |
239 | */ | 239 | */ |
240 | public static function utf8ize($data) | 240 | public static function utf8ize($data) |
241 | { | 241 | { |
242 | if (is_array($data)) | 242 | if (is_array($data)) |
243 | { | 243 | { |
244 | foreach ($data as $k => $v) | 244 | foreach ($data as $k => $v) |
245 | { | 245 | { |
246 | $data[$k] = self::utf8ize($v); | 246 | $data[$k] = self::utf8ize($v); |
247 | } | 247 | } |
248 | } | 248 | } |
249 | else if (is_string ($data)) | 249 | else if (is_string ($data)) |
250 | { | 250 | { |
251 | return utf8_encode($data); | 251 | if ('' == mb_detect_encoding($data)) |
252 | { | ||
253 | return utf8_encode($data); | ||
254 | } | ||
255 | else | ||
256 | { | ||
257 | return $data; | ||
258 | } | ||
252 | } | 259 | } |
253 | return $data; | 260 | return $data; |
254 | } | 261 | } |