Gestion de l'UTF-8

This commit is contained in:
Michael RICOIS 2015-09-04 10:06:41 +00:00
parent 13950bc000
commit 9c97dcb57d

View File

@ -24,12 +24,15 @@ function initstr($chaine, $taille, $caractere_pour_combler=' ', $align=ALIGN_LEF
return substr($chaine, 0, $taille);
}
$encoding = mb_internal_encoding();
$diff = strlen($chaine) - mb_strlen($chaine, $encoding);
if ($align == ALIGN_RIGHT) {
return str_pad($chaine ,$taille, $caractere_pour_combler, STR_PAD_LEFT);
}
return str_pad($chaine, $taille + $diff, $caractere_pour_combler, STR_PAD_LEFT);
}
if ($align == ALIGN_LEFT) {
return str_pad($chaine, $taille, $caractere_pour_combler, STR_PAD_RIGHT);
return str_pad($chaine, $taille + $diff, $caractere_pour_combler, STR_PAD_RIGHT);
}
return $str;