downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

mb_encode_mimeheader> <mb_detect_encoding
[edit] Last updated: Fri, 17 May 2013

view this page in

mb_detect_order

(PHP 4 >= 4.0.6, PHP 5)

mb_detect_orderEstablece/obtiene el orden de detección de codificaciones de caracteres

Descripción

mixed mb_detect_order ([ mixed $encoding_list ] )

Establece el orden de detección automática de la codificación de caracteres a encoding_list.

Parámetros

encoding_list

encoding_list es un array o una lista de codificaciones de caracteres separadas por comas. Véanse las codificaciones admitidas.

Si se omite encoding_list, devolverá el orden actual de detección de las codificaciones de caracteres como un array.

Este parámetro afecta a mb_detect_encoding() y a mb_send_mail().

mbstring actualmente implementa los siguientes filtros de detección de codificaciones. Si existiera una secuencia de bytes inválida para las siguientes codificaciones, la detección de la codificación fallará.

UTF-8, UTF-7, ASCII, EUC-JP,SJIS, eucJP-win, SJIS-win, JIS, ISO-2022-JP

Para ISO-8859-*, mbstring siempre lo detecta como ISO-8859-*.

Para UTF-16, UTF-32, UCS2 y UCS4, la detección de la codificación siempre fallará.

Ejemplo #1 Ejemplo orden de detección inútil

; Siempre es detectado como ISO-8859-1
detect_order = ISO-8859-1, UTF-8

; Siempre es detectado como UTF-8, ya que los valores ASCII/UTF-7 son 
; válidos para UTF-8
detect_order = UTF-8, ASCII, UTF-7

Valores devueltos

Devuelve TRUE en caso de éxito o FALSE en caso de error.

Ejemplos

Ejemplo #2 Ejemplo de mb_detect_order()

<?php
/* Establecer el orden de detección mediante una lista enumerada */
mb_detect_order("eucjp-win,sjis-win,UTF-8");

/* Establecer el orden de detección mediante un array */
$ary[] = "ASCII";
$ary[] = "JIS";
$ary[] = "EUC-JP";
mb_detect_order($ary);

/* Mostrar el orden de detección en uso */
echo implode(", "mb_detect_order());
?>

Ver también



add a note add a note User Contributed Notes mb_detect_order - [1 notes]
up
0
ben at sixg dot com
9 years ago
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().)

 
show source | credits | stats | sitemap | contact | advertising | mirror sites