Linux文件编码乱码时解决方法

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>文件编码错误修正</title>
</head>

<body>
<?php
$stime = strtotime('2014-06-06 16:00:00');
$etime = strtotime('2014-06-09 11:00:00');
$dir = "../uploads/member/temp/201406/";
$list = scandir($dir);
foreach($list as $v ){
	if(filemtime($dir.$v) > $stime && filemtime($dir.$v) < $etime){
		$file = $dir.$v;
		$unixfile = mb_convert_encoding($dir.$v, "UTF-8","GBK");
		if (@copy($file, $unixfile))
			echo "copy('$file','$unixfile');<br />";
		else{
			echo "Error copy('$file','$unixfile');<br />";
		}
		unlink($file);
	}
}
?>
</body>
</html>




你可能感兴趣的:(Linux文件编码乱码时解决方法)