diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 4a95bb7d345..1d3a091cab1 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8402,8 +8402,6 @@ abstract class CommonObject $photo = ''; $file = $val['name']; - //if (! utf8_check($file)) $file=utf8_encode($file); // To be sure file is stored in UTF8 in memory - //if (dol_is_file($dir.$file) && image_format_supported($file) >= 0) if (image_format_supported($file) >= 0) { $nbphoto++; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 13ccde98bf2..7e95bf0e95f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -42,6 +42,34 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; + +if (!function_exists('utf8_encode')) { + /** + * Implement utf8_encode for PHP that does not support it. + * + * @param mixed $elements PHP Object to json encode + * @return string Json encoded string + */ + function utf8_encode($elements) + { + return mb_convert_encoding($elements, 'UTF-8', 'ISO-8859-1'); + } +} + +if (!function_exists('utf8_decode')) { + /** + * Implement utf8_decode for PHP that does not support it. + * + * @param mixed $elements PHP Object to json encode + * @return string Json encoded string + */ + function utf8_decode($elements) + { + return mb_convert_encoding($elements, 'ISO-8859-1', 'UTF-8'); + } +} + + /** * Return dolibarr global constant string value * @param string $key key to return value, return '' if not set diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 67fb1772ac4..5fae77938e8 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -2319,9 +2319,8 @@ class Ticket extends CommonObject if (is_resource($handle)) { while (($file = readdir($handle)) !== false) { if (!utf8_check($file)) { - $file = utf8_encode($file); + $file = utf8_encode($file); // To be sure data is stored in UTF8 in memory } - // To be sure data is stored in UTF8 in memory if (dol_is_file($dir.$file)) { return true; } diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 6e15359056a..2a5f4cc59fe 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -885,7 +885,6 @@ if ($action == 'addcontainer' && $usercanedit) { } else { // Clean some comment //$tmpgeturl['content'] = dol_string_is_good_iso($tmpgeturl['content'], 1); - //$tmpgeturl['content'] = utf8_encode(utf8_decode($tmpgeturl['content'])); //$tmpgeturl['content'] = mb_convert_encoding($tmpgeturl['content'], 'UTF-8', 'UTF-8'); //$tmpgeturl['content'] = remove_bs($tmpgeturl['content']); //$tmpgeturl['content'] = str_replace('$screen-md-max', 'auto', $tmpgeturl['content']);