mb_detect_encoding
(PHP 4 >= 4.0.6, PHP 5)
mb_detect_encoding — Detect character encoding
说明
string mb_detect_encoding ( string $str [, mixed $encoding_list = mb_detect_order() [, bool $strict = false ]] )Detects character encoding in string str.
参数
- str
-
The string being detected.
- encoding_list
-
encoding_list is list of character encoding. Encoding order may be specified by array or comma separated list string.
If encoding_list is omitted, detect_order is used.
- strict
-
strict specifies whether to use the strict encoding detection or not. Default is FALSE.
返回值
The detected character encoding or FALSE if the encoding cannot be detected from the given string.
范例
Example #1 mb_detect_encoding() example
<?php
echo mb_detect_encoding($str);
echo mb_detect_encoding($str, "auto");
echo mb_detect_encoding($str, "JIS, eucjp-win, sjis-win");
$ary[] = "ASCII";
$ary[] = "JIS";
$ary[] = "EUC-JP";
echo mb_detect_encoding($str, $ary);
?>
参见
- mb_detect_order() - Set/Get character encoding detection order