Skip to content
Extraits de code Groupes Projets
Valider 74c77963 rédigé par Fil's avatar Fil
Parcourir les fichiers

contourner le bug windows sur is_utf8 (et is_ascii, a priori, qui devrait avoir le même souci)

parent 28e7b5c4
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -508,7 +508,7 @@ function bom_utf8($texte) { ...@@ -508,7 +508,7 @@ function bom_utf8($texte) {
// http://w3.org/International/questions/qa-forms-utf-8.html // http://w3.org/International/questions/qa-forms-utf-8.html
function is_utf8($string) { function is_utf8($string) {
return preg_match(',^(?:' return preg_match(',^(?:'
. '[\x09\x0A\x0D\x20-\x7E]' # ASCII . '[\x20-\x7E]' # ASCII
. '|[\xC2-\xDF][\x80-\xBF]' # non-overlong 2-byte . '|[\xC2-\xDF][\x80-\xBF]' # non-overlong 2-byte
. '|\xE0[\xA0-\xBF][\x80-\xBF]' # excluding overlongs . '|\xE0[\xA0-\xBF][\x80-\xBF]' # excluding overlongs
. '|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}' # straight 3-byte . '|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}' # straight 3-byte
...@@ -516,10 +516,14 @@ function is_utf8($string) { ...@@ -516,10 +516,14 @@ function is_utf8($string) {
. '|\xF0[\x90-\xBF][\x80-\xBF]{2}' # planes 1-3 . '|\xF0[\x90-\xBF][\x80-\xBF]{2}' # planes 1-3
. '|[\xF1-\xF3][\x80-\xBF]{3}' # planes 4-15 . '|[\xF1-\xF3][\x80-\xBF]{3}' # planes 4-15
. '|\xF4[\x80-\x8F][\x80-\xBF]{2}' # plane 16 . '|\xF4[\x80-\x8F][\x80-\xBF]{2}' # plane 16
. ')*$,s', $string); . ')*$,s',
strtr($string, "\t\r\n", " ") # contourner bug windows sur \r
);
} }
function is_ascii($string) { function is_ascii($string) {
return preg_match(',^[\x09\x0A\x0D\x20-\x7E]*$,s', $string); return preg_match(',^[\x20-\x7E]*$,s',
strtr($string, "\t\r\n", " ")
);
} }
// Transcode une page (attrapee sur le web, ou un squelette) en essayant // Transcode une page (attrapee sur le web, ou un squelette) en essayant
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter