From 7d30a11a26739aadc8b2778f72af84b530bbc4cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 27 Oct 2020 20:06:49 +0100 Subject: [PATCH] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 6b76148d350..641ec29781e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1086,27 +1086,36 @@ function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0, $keepmoreta } } - /** * Convert a string to lower. Never use strtolower because it does not works with UTF8 strings. * - * @param string $utf8_string String to encode + * @param string $string String to encode + * @param string $encoding Character set encoding * @return string String converted */ -function dol_strtolower($utf8_string) +function dol_strtolower($string, $encoding = "UTF-8") { - return mb_strtolower($utf8_string, "UTF-8"); + if (function_exists('mb_strtolower')) { + return mb_strtolower($string, $encoding); + } else { + return strtolower($string); + } } /** * Convert a string to upper. Never use strtolower because it does not works with UTF8 strings. * - * @param string $utf8_string String to encode + * @param string $string String to encode + * @param string $encoding Character set encoding * @return string String converted */ -function dol_strtoupper($utf8_string) +function dol_strtoupper($string, $encoding = "UTF-8") { - return mb_strtoupper($utf8_string, "UTF-8"); + if (function_exists('mb_strtoupper')) { + return mb_strtoupper($string, $encoding); + } else { + return strtoupper($string); + } }