博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
php 给文件转码,php如何给文件转码
阅读量:6915 次
发布时间:2019-06-27

本文共 466 字,大约阅读时间需要 1 分钟。

php给文件转码的方法是:首先使用mb_detect_encoding()函数判断文件使用的编码;然后再使用函数mb_convert_encoding()来为文件进行转码即可。

af801ed11ac84a5c2f0f6c9115af296b.png

相关函数介绍:

(推荐教程:php教程)

mb_convert_encoding()函数转换字符编码。

mb_detect_encoding() 函数判断字符串使用的编码。

函数语法:

mb_convert_encoding($str,$encoding1,$encoding2);

代码实现:

function characet($data){

if( !empty($data) ){

$fileType = mb_detect_encoding($data , array('UTF-8','GBK','LATIN1','BIG5')) ;

if( $fileType != 'UTF-8'){

$data = mb_convert_encoding($data ,'utf-8' , $fileType);

}

}

return $data;

}

转载地址:http://gjncl.baihongyu.com/

你可能感兴趣的文章
天猫与九大快递合作 价格热战之后的冷静竞争
查看>>
git pull force
查看>>
scons用户手册
查看>>
使用new操作符来调用一个构造函数的时候发生了什么
查看>>
element-ui之el-scrollbar源码解析学习
查看>>
ceph 的pg诊断
查看>>
交换机配置vlan 访问控制列表
查看>>
我的友情链接
查看>>
12个时间管理妙招
查看>>
Python面向对象之类的成员
查看>>
Win8上iis配置
查看>>
Confluence 6 配置 Office 转换器
查看>>
IT从业人员关注哪些问题
查看>>
Windows 2012 Hyper –V 3.0 New Functions
查看>>
maven部分插件配置demo
查看>>
Grin交易原理详解
查看>>
大数据体系【概念认知】系列-2:存储以及副本策略
查看>>
我的友情链接
查看>>
linux企业常用服务---haproxy+nginx搭建web高可用集群
查看>>
win7 断开 共享连接的操作方法
查看>>