Note that as of mbstring.c version 1.142.2.31, first released as PHP 4.3.4RC3, "auto" has changed meaning. It used to be configured based on #defines, so it was set at compile time, so for precompiled binary users (esp. Windows users) it has always been the same (Japanese mode). However, it is now based on the language that mbstring is configured for at runtime. (setlocale() doesn't affect this though) Running on English Windows at least, mbstring defaults to a "neutral" mode which results in an "auto" list of "ASCII, UTF-8". So, the point is, for PHP 4.3.4 or newer, you probably want to either use mb_language("Japanese") followed by mb_detect_order("auto"), or just hardcode your detect order with mb_detect_order("ASCII, JIS, UTF-8, EUC-JP, SJIS"). (Also note that mb_language() alone won't do it, you'll have to set the detect order to "auto" _after_ calling mb_language().)
mb_detect_order
(PHP 4 >= 4.0.6, PHP 5)
mb_detect_order — Lit/modifie l'ordre de détection des encodages
Description
Remplace l'ordre de détection des encodages courant par encoding_list .
Liste de paramètres
- encoding_list
-
encoding_list est un tableau, ou une liste d'encodages séparés par une virgule. La valeur "auto" est automatiquement remplacée par "ASCII, JIS, UTF-8, EUC-JP, SJIS".
Si encoding_list est omis, mb_detect_order() retourne l'ordre de détection courant des encodages dans un tableau.
Ce paramétrage affecte les fonctions mb_detect_encoding() et mb_send_mail().
Actuellement, mbstring supporte les filtres de détections ci-dessous. Si une séquence d'octets est invalide pour l'un des filtres suivants, la détection échouera.
UTF-8, UTF-7, ASCII, EUC-JP,SJIS, eucJP-win, SJIS-win, JIS, ISO-2022-JPPour ISO-8859-*, mbstring détecte toujours ISO-8859-*.
Pour UTF-16, UTF-32, UCS2 et UCS4 la détection échouera toujours.
Exemple #1 Exemple d'ordre de détection inutile
; Toujours détecté comme ISO-8859-1 detect_order = ISO-8859-1, UTF-8 ; Toujours détecté comme UTF-8, depuis que les valeurs ASCII/UTF-7 ; sont valides pour UTF-8 detect_order = UTF-8, ASCII, UTF-7
Valeurs de retour
Cette fonction retourne TRUE en cas de succès, FALSE en cas d'échec.
Exemples
Exemple #2 Exemple avec mb_detect_order()
<?php
/* Remplace l'ordre de détection par une liste énumérée */
mb_detect_order("eucjp-win,sjis-win,UTF-8");
/* Remplace l'ordre de détection par un tableau */
$ary[] = "ASCII";
$ary[] = "JIS";
$ary[] = "EUC-JP";
mb_detect_order($ary);
/* Affiche l'ordre de détection courant */
echo implode(", ", mb_detect_order());
?>
mb_detect_order
21-Apr-2004 05:31
