.01
.02
.03
.04
.05
.06
.07
.08
.09
.10
.11
.12
.13
.14
.15
.16
.17
.18
.19
.20
.21
.22
.23
.24
.25
.26
.27
.28
.29
.30
.31
.32
.33
.34
.35
.36
.37
.38
.39
.40
.41
.42
.43
.44
.45
.46
.47
.48
.49
.50
.51
.52
|
|
<?php
/******************************************************************************/
/* */
/* __ ____ */
/* ___ / / ___ / __/__ __ _____________ ___ */
/* / _ \/ _ \/ _ \_\ \/ _ \/ // / __/ __/ -_|_-< */
/* / .__/_//_/ .__/___/\___/\_,_/_/ \__/\__/___/ */
/* /_/ /_/ */
/* */
/* */
/******************************************************************************/
/* */
/* Titre : C'est de l'UTF8 ou de l'ISO ? */
/* */
/* URL : http://www.phpsources.org/scripts320-PHP.htm */
/* Auteur : KOogar */
/* Date édition : 29 Déc 2007 */
/* Website auteur : http://www.phpsources.org */
/* */
/******************************************************************************/
function test_utf8($str)
{
// astuce pour entrer dans un test booléen ^^
// (si c'est un tableau... ce qui est forcement vrai)
if (is_array($str)) {
$str = implode('', $str);
// retourne FALSE si aucun caractere n'appartient au jeu utf8
return !((ord($str[0]) != 239) && (ord($str[1]) != 187) && (ord($str[2]) != 191));
}
else {
// retourne TRUE
// si la chaine decoder et encoder est egale a elle meme
return (utf8_encode(utf8_decode($str)) == $str);
}
}
// votre chaine ou fichier texte
$str = "Le terme a été créé en 1903 par Carl Neuberg d'après";
// c'est ici que l'on apel la fonction
// si c'est egal a 0, encode en utf8
if (!$test_utf8) $str = utf8_encode($str);
// affiche
echo $str;
// devrait afficher une chaine de ce genre
// Le terme a été créé en 1903 par Carl Neuberg d'après
?>
|