- <?php
- /**
- * Transforme toutes les chaines qu'elles soit utf8 ou iso en utf8
- */
- class stringConverter_utf8 extends stringConverter {
- function convertString($string)
- {
- if ($this->string_type == 'utf-8')
- return $string;
- else
- return utf8_encode($string);
- }
- }
- /**
- * Transforme touT en iso
- */
- class stringConverter_iso extends stringConverter {
- function convertString($string)
- {
- if ($this->string_type == 'utf-8')
- return utf8_decode($string);
- else
- return $string;
- }
- }
-
- class stringConverter {
- var $string_type = ''; //Type d'encodage
- var $utf = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789²&é"\'(-è_çà)=~#{[|`\^@]}¨^$£¤ù%*µ!§:/;.?,<>€îïâûüψΨωΩΧχΦφÛÊËÜÏÎñÑõÕ‰ƒ¾½¼³¹º±×÷ÁáÀÂÅåãÃäÄæÆçÇéÉÈÌíÍìøØßÿ´`αΑβΒγΓδΔεΕζΖηΗθΘιΙκΚλΛμΜνΝξΞοΟπΠρΡσςΣτΤυΥ–—¡¿&¢©µ·¶£®§¥™"«»…';
-
- function __construct(){
- $this->utf8_caracteres= preg_split('//', $this->utf, -1, PREG_SPLIT_NO_EMPTY);
- }
- function analyse($string)
- {
- $this->chars = preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY);
- foreach($this->chars as $char) {
- if ($this->string_type == '')
- $this->string_type = $this->analyseChar($char);
- else{
- $s=$this->convertString($string);
- $analyser->string_type='';
- return $s;
- }
- }
- return $string;
- }
-
- protected function analyseChar($char)
- {
- if (utf8_encode($char) == utf8_decode($char))
- return $this->string_type;
- if (in_array($char,$this->utf8_caracteres))
- return 'utf-8';
- return 'iso-8859-1';
- }
- }
-
- ?>
<?php
/**
* Transforme toutes les chaines qu'elles soit utf8 ou iso en utf8
*/
class stringConverter_utf8 extends stringConverter {
function convertString($string)
{
if ($this->string_type == 'utf-8')
return $string;
else
return utf8_encode($string);
}
}
/**
* Transforme touT en iso
*/
class stringConverter_iso extends stringConverter {
function convertString($string)
{
if ($this->string_type == 'utf-8')
return utf8_decode($string);
else
return $string;
}
}
class stringConverter {
var $string_type = ''; //Type d'encodage
var $utf = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789²&é"\'(-è_çà)=~#{[|`\^@]}¨^$£¤ù%*µ!§:/;.?,<>€îïâûüψΨωΩΧχΦφÛÊËÜÏÎñÑõÕ‰ƒ¾½¼³¹º±×÷ÁáÀÂÅåãÃäÄæÆçÇéÉÈÌíÍìøØßÿ´`αΑβΒγΓδΔεΕζΖηΗθΘιΙκΚλΛμΜνΝξΞοΟπΠρΡσςΣτΤυΥ–—¡¿&¢©µ·¶£®§¥™"«»…';
function __construct(){
$this->utf8_caracteres= preg_split('//', $this->utf, -1, PREG_SPLIT_NO_EMPTY);
}
function analyse($string)
{
$this->chars = preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY);
foreach($this->chars as $char) {
if ($this->string_type == '')
$this->string_type = $this->analyseChar($char);
else{
$s=$this->convertString($string);
$analyser->string_type='';
return $s;
}
}
return $string;
}
protected function analyseChar($char)
{
if (utf8_encode($char) == utf8_decode($char))
return $this->string_type;
if (in_array($char,$this->utf8_caracteres))
return 'utf-8';
return 'iso-8859-1';
}
}
?>