mb_detect_encoding 判断不到档案是unicode我用记事本把内容储存为unicode编码<?php
$file='01.txt';
$str=file_get_contents($file);
echo $c=mb_detect_encoding($str);
$str=iconv($c, 'UTF-8//IGNORE', $str);
//$str=iconv('UTF-16', 'UTF-8//IGNORE', $str);
file_put_contents('01_utf8.txt',$str);
?>如果用这句能成功转为utf8
$str=iconv('UTF-16', 'UTF-8//IGNORE', $str);
但我不能不检测档案是什么编码,档案可能是上传来的有什么方法判断档案是unicode / UTF-16 ?