mb_detect_encoding

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

mb_detect_encoding锟斤拷锟斤拷址锟斤拷谋锟斤拷锟�

说锟斤拷

mb_detect_encoding ( string $str [, mixed $encoding_list = mb_detect_order() [, bool $strict = false ]] ) : string

锟斤拷锟�锟街凤拷锟斤拷 str 锟侥憋拷锟诫。

锟斤拷锟斤拷

str

锟斤拷锟斤拷锟斤拷锟街凤拷锟斤拷锟斤拷

encoding_list

encoding_list 锟斤拷一锟斤拷锟街凤拷锟斤拷锟斤拷锟叫憋拷 锟斤拷锟斤拷顺锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟竭讹拷锟脚分革拷锟斤拷锟叫憋拷锟街凤拷锟斤拷指锟斤拷锟斤拷

锟斤拷锟绞★拷锟斤拷锟� encoding_list 锟斤拷锟斤拷使锟斤拷 detect_order锟斤拷

strict

strict 指锟斤拷锟斤拷锟角凤拷锟较革拷丶锟斤拷锟斤拷搿� 默锟斤拷锟斤拷 FALSE锟斤拷

锟斤拷锟斤拷值

锟斤拷獾斤拷锟斤拷址锟斤拷锟斤拷耄拷锟斤拷锟斤拷薹锟斤拷锟斤拷指锟斤拷锟街凤拷锟斤拷锟侥憋拷锟斤拷时锟斤拷锟斤拷 FALSE锟斤拷

锟斤拷锟斤拷

Example #1 mb_detect_encoding() 锟斤拷锟斤拷

<?php
/* 使锟矫碉拷前锟斤拷 detect_order 锟斤拷锟斤拷锟斤拷址锟斤拷锟斤拷锟� */
echo mb_detect_encoding($str);

/* "auto" 锟斤拷锟斤拷锟斤拷 mbstring.language 锟斤拷锟斤拷展 */
echo mb_detect_encoding($str"auto");

/* 通锟斤拷锟斤拷锟脚分革拷锟斤拷锟叫憋拷锟斤拷指锟斤拷锟斤拷锟斤拷锟叫憋拷 encoding_list */
echo mb_detect_encoding($str"JIS, eucjp-win, sjis-win");

/* 使锟斤拷锟斤拷锟斤拷锟斤拷指锟斤拷锟斤拷锟斤拷锟叫憋拷 encoding_list  */
$ary[] = "ASCII";
$ary[] = "JIS";
$ary[] = "EUC-JP";
echo 
mb_detect_encoding($str$ary);
?>

锟轿硷拷

  • mb_detect_order() - 锟斤拷锟斤拷/锟斤拷取 锟街凤拷锟斤拷锟斤拷募锟斤拷顺锟斤拷