大家好,最近遇到了一个棘手的问题,用php生成csv文件时 西欧字符显示成乱码, 请问怎样解决,谢谢。 下面是代码$URL="/CSVfiles.csv";
$content="Provence-Alpes-Côte";
file_put_contents($URL,$content);
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=".$URL."");
readfile($URL);下载的csv文件中字符 ô 显示的就是乱码,请问大家怎样正确显示,谢谢。
$content="Provence-Alpes-Côte";
file_put_contents($URL,$content);
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=".$URL."");
readfile($URL);下载的csv文件中字符 ô 显示的就是乱码,请问大家怎样正确显示,谢谢。
return iconv("ISO-8859-1","GB2312",$String);//转换成GB2312编码
}$URL="/CSVfiles.csv";
$content="Provence-Alpes-Côte";
$content = ConvertStringCharset($content);
file_put_contents($URL,$content);
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=".$URL."");
readfile($URL);
试试看
需要在写文件内容前加上BOM头