From 2d597d6d47eac9d60c8d36f6d4a63ab77bdce28d Mon Sep 17 00:00:00 2001 From: b_b <brunobergot@gmail.com> Date: Wed, 16 Mar 2016 19:03:02 +0000 Subject: [PATCH] =?UTF-8?q?ajout=20d'une=20fonction=20spip=5Fstrtolower=20?= =?UTF-8?q?pour=20g=C3=A9rer=20strtolower=20en=20utf8,=20cf=20#3624?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ecrire/inc/charsets.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/ecrire/inc/charsets.php b/ecrire/inc/charsets.php index 8ff3d5aaee..9c1a51ce40 100644 --- a/ecrire/inc/charsets.php +++ b/ecrire/inc/charsets.php @@ -100,6 +100,7 @@ function init_mb_string() { and function_exists('mb_detect_order') and function_exists('mb_substr') and function_exists('mb_strlen') + and function_exists('mb_strtolower') and function_exists('mb_encode_mimeheader') and function_exists('mb_encode_numericentity') and function_exists('mb_decode_numericentity') @@ -1157,6 +1158,29 @@ function spip_ucfirst($c) { return $lettre1 . spip_substr($c, 1); } +/** + * Passe une chaÎne utf-8 en minuscules + * + * Version utf-8 de strtolower + * + * @param string $c + * La chaÎne à transformer + * @return string + * La chaÎne en minuscules + */ +function spip_strtolower($c) { + // Si ce n'est pas utf-8, utiliser strtolower + if ($GLOBALS['meta']['charset'] != 'utf-8') { + return strtolower($c); + } + // Si on n'a pas mb_* on utilise strtolower + if (!init_mb_string()) { + return strtolower($c); + } + + return mb_strtolower($c); +} + /** * Retourne la longueur d'une chaÎne utf-8 * -- GitLab