批量 gb->utf-8编码转换. (转)
来源:互联网 发布:大战神神翼进阶数据 编辑:程序博客网 时间:2024/04/26 04:00
<?
//文件编码转换.
function file_iconv($fromcode,$tocode,$file){
$data = join('',file($file));
if(preg_match('/charset='.str_replace('-','/-',$tocode).'/mis',$data)){
echo "<font color='red'>$file $tocode .</font>";
}
$data = preg_replace('/charset='.str_replace('-','/-',$fromcode).'/mis',"charset=$tocode",$data);
$data = preg_replace('/(sets+namess+)''.str_replace('-','',$fromcode).''/mis',"/1'".str_replace('-','',$tocode)."'",$data);
$data = iconv("$fromcode","$tocode",$data);
$fp = fopen("$file","w");
fwrite($fp,$data);
fclose($fp);
echo "$file ...<br>";
}
function listfiles($dir="."){
$handle=opendir("$dir");
while ($file = readdir($handle)) {
if($file=="."||$file=="..")continue;
if(is_dir("$dir/$file")){
listfiles("$dir/$file");
}
else {
$ext = strtolower(strrchr($file,'.'));
if(in_array($ext,array(".php",".html",".htm"))){
file_iconv("gb2312","utf-8","$dir/$file");
}
}
}
closedir($handle);
}
listfiles("mydir");
?>
- 批量 gb->utf-8编码转换. (转)
- GB/BIG5/UTF-8 文件编码批量转换程序
- GB编码转UTF
- utf-8 & gb 转换
- 网页源文件编码转换(UTF-8或BIG-5转换为GB)
- UTF-8与GB 2312编码
- linux下GBK->UTF-8文件编码批量转换脚本
- linux下GBK->UTF-8文件编码批量转换脚本
- Linux下GBK->UTF-8文件编码批量转换命令
- linux 下 GBK-UTF-8文件编码批量转换脚本
- linux 批量转换文本编码为UTF-8
- Linux下批量转换到utf-8编码的问题
- 批量文件编码转换(GBK/UTF-8/UNICODE etc)
- 使用iconv批量转换文件编码为utf-8
- Linux下GBK文件编码批量转换UTF-8命令
- linux 批量转换GBK到UTF-8编码的方法
- 编码: ASCII(ANSI), GB-2312, UNICODE, UTF-8,UTF-16
- 多线程批量转换文件编码, 从GBK, GB2312编码转换到UTF-8编码(Python)
- linux下安装jdk6.0,tomcat5.5,mysql6.0,eclipse,netbeans6.0
- css手记
- hp我卑视你
- C#常见的持久层框架
- 打造自己的asp.net验证控件
- 批量 gb->utf-8编码转换. (转)
- 使用Application、Session、Cookie、ViewState和Cache等对象保存信息的区别
- Exception in thread "main" java.lang.NoClassDefFoundError
- ASP.NET页面生命周期概述
- 4月1日 Google也搞笑
- ACE配置
- PATINDEX()的用法
- Hibernate的C3P详细配置
- CVS添加用户的过程和命令列表