判断字符串是否为 utf-8 编码
2014-06-05 13:25
363 查看
代码清单:
声明:本文来自CSDN,转载请注明出处!
<?php /** * 判断字符串是否为utf8编码,英文和半角字符返回ture * @author ruxing.li * @param $string * @return bool */ function is_utf8($string) { return preg_match('%^(?: [\x09\x0A\x0D\x20-\x7E] # ASCII | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3 | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15 | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 )*$%xs', $string); }
声明:本文来自CSDN,转载请注明出处!
相关文章推荐
- PHP实例——判断字符串是否为UTF-8编码
- 判断字符串(UTF-8编码)是否为中文、韩文、日文的LUA实现
- 【转】判断某字符串是否是UTF-8编码
- PHP判断字符串编码是否utf8并转换的方法
- VC++ 判断文本文件是否UTF-8编码
- 用VBS判断无BOM头的文件是否UTF-8编码
- Android工具类,一些方法电话正则,是否为空,日期格式化,星期,车牌,身份证校验,设置地区编码,验证日期字符串是否是YYYY-MM-DD格式,判断字符串是否为数字
- MySQL创建数据库时判断是否存在,mysql create database 指定utf-8编码
- 判断字符串是否有包含关系(包括中文,中文注意编码格式)
- PHP判断字符串编码是否utf8并转换的方法
- 判断文件编码是否为UTF
- 如何识别字符串是否是UTF-8编码的
- 检测字符串是否为utf-8编码代码
- 无BOM的条件下C语言判断一个文件是否为UTF-8编码代码(windows,linux通用)
- 判断文件编码是否为UTF-8收藏
- 根据字节流判断内容是否使用UTF-8编码
- php检测字符串编码(utf-8,gbk,gb2312)是否为utf8编码的方法总结
- PHP判断字符串编码是否utf8并转换的方法
- vc 如何判断一个字符串是否是UTF8编码
- 判断文件是否是UTF-8编码