文字

mb_detect_order

(PHP 4 >= 4.0.6, PHP 5)

mb_detect_order设置/获取 字符编码的检测顺序

说明

mixed mb_detect_order ([ mixed $encoding_list = mb_detect_order() ] )

为编码列表 encoding_list 设置自动检测字符编码的顺序。

参数

encoding_list

encoding_list 是一个 array 或者逗号分隔的字符编码列表。 参见支持的编码。

如果省略了 encoding_list 参数,它将返回当前字符编码检测顺序的数组。

该设置会影响 mb_detect_encoding() mb_send_mail()

mbstring 当前实现了以下编码检测筛选器。 如有以下编码列表的无效字节序列,编码的检测将会失败。

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

对于 ISO-8859-*mbstring 总是检测为 ISO-8859-*

对于 UTF-16UTF-32UCS2UCS4,编码检测总是会失败。

返回值

成功时返回 TRUE , 或者在失败时返回 FALSE

范例

Example #1 mb_detect_order() 例子

<?php

mb_detect_order ( "eucjp-win,sjis-win,UTF-8" );


$ary [] =  "ASCII" ;
$ary [] =  "JIS" ;
$ary [] =  "EUC-JP" ;
mb_detect_order ( $ary );


echo  implode ( ", " mb_detect_order ());
?>

Example #2 案例展示了无效的检测顺序

; 总是检测为 ISO-8859-1
detect_order = ISO-8859-1, UTF-8; 总是检测为 UTF-8,由于 ASCII/UTF-7 的值对  UTF-8 是有效的
detect_order = UTF-8, ASCII, UTF-7

参见

  • mb_internal_encoding() - 设置/获取内部字符编码
  • mb_http_input() - 检测 HTTP 输入字符编码
  • mb_http_output() - 设置/获取 HTTP 输出字符编码
  • mb_send_mail() - 发送编码过的邮件
上一篇: 下一篇: