From 5f01b7fe7dbc4cf2f05365e8f00e27e2817f1725 Mon Sep 17 00:00:00 2001 From: Teromene Date: Tue, 19 Jan 2016 12:17:27 +0000 Subject: [PATCH] Added a function to re-encode everything to UTF-8 --- lib/Cache.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/Cache.php b/lib/Cache.php index fa80bc0..a165148 100644 --- a/lib/Cache.php +++ b/lib/Cache.php @@ -70,6 +70,26 @@ class Cache{ return preg_match('@^[A-Z][a-zA-Z0-9-]*$@', $nameCache); } + + static public function utf8_encode_deep(&$input) { + if (is_string($input)) { + $input = utf8_encode($input); + } else if (is_array($input)) { + foreach ($input as &$value) { + Cache::utf8_encode_deep($value); + } + + unset($value); + } else if (is_object($input)) { + $vars = array_keys(get_object_vars($input)); + + foreach ($vars as $var) { + Cache::utf8_encode_deep($input->$var); + } + } + } + + static public function purge() { $cacheTimeLimit = time() - 60*60*24 ; $cachePath = 'cache';