diff --git a/ecrire/inc/charsets.php b/ecrire/inc/charsets.php index 8ff3d5aaee4403fb4876f7cd899bb0acc5e779a5..9c1a51ce4038d9fa21a48f0ba0d3ea3c5d2a1908 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 *