diff --git a/ecrire/inc_charsets.php b/ecrire/inc_charsets.php index e07ced7d016e8ec4f02c1536fac4c8a2e35367cf..9813e8c6b03668590e2d2216f6c217d9bbef211f 100644 --- a/ecrire/inc_charsets.php +++ b/ecrire/inc_charsets.php @@ -508,7 +508,7 @@ function bom_utf8($texte) { // http://w3.org/International/questions/qa-forms-utf-8.html function is_utf8($string) { return preg_match(',^(?:' - . '[\x09\x0A\x0D\x20-\x7E]' # ASCII + . '[\x20-\x7E]' # ASCII . '|[\xC2-\xDF][\x80-\xBF]' # non-overlong 2-byte . '|\xE0[\xA0-\xBF][\x80-\xBF]' # excluding overlongs . '|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}' # straight 3-byte @@ -516,10 +516,14 @@ function is_utf8($string) { . '|\xF0[\x90-\xBF][\x80-\xBF]{2}' # planes 1-3 . '|[\xF1-\xF3][\x80-\xBF]{3}' # planes 4-15 . '|\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) { - 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