首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

mb_detect_encoding

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

mb_detect_encoding - 检测字符编码

描述

代码语言:javascript
复制
string mb_detect_encoding ( string $str [, mixed $encoding_list = mb_detect_order() [, bool $strict = false ]] )

检测str字符串中的字符编码。

参数

str

正在检测的字符串。

encoding_list

encoding_list是字符编码的列表。编码顺序可以由数组或逗号分隔的列表字符串指定。

如果encoding_list省略,则使用 detect_order。

strict

strict指定是否使用严格编码检测。默认是FALSE

返回值

检测到的字符编码或者FALSE是否无法从给定字符串中检测到编码。

示例

示例#1 mb_detect_encoding()示例

代码语言:javascript
复制
<?php
/*?Detect?character?encoding?with?current?detect_order?*/
echo?mb_detect_encoding($str);

/*?"auto"?is?expanded?according?to?mbstring.language?*/
echo?mb_detect_encoding($str,?"auto");

/*?Specify?encoding_list?character?encoding?by?comma?separated?list?*/
echo?mb_detect_encoding($str,?"JIS,?eucjp-win,?sjis-win");

/*?Use?array?to?specify?encoding_list??*/
$ary[]?=?"ASCII";
$ary[]?=?"JIS";
$ary[]?=?"EUC-JP";
echo?mb_detect_encoding($str,?$ary);
?>

也可以看看

  • mb_detect_order() - 设置/获取字符编码检测顺序

← mb_decode_numericentity

mb_detect_order →

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com