问题描述
我正在研究一个PHP脚本,该脚本根据一些数据创建一个.csv文件。
不幸的是,在Umlaut中不能正确显示Umlaut:Löl
变成L√∂l
(这仅在Excel中,在Apple的Numbers,Atom和Textedit中,一切看起来都很好)。
我尝试了数百种函数来尝试正确地进行编码(请参见下面的注释函数)。有人可以告诉我我在做什么错吗?
$rows = json_decode('[["Löl"]]');
foreach($rows as $key_row => $row) {
foreach($row as $key_cell => $cell) {
// $rows[$key_row][$key_cell] = utf8_decode($cell);
// $rows[$key_row][$key_cell] = iconv('UTF-8','Windows-1252',$cell);
// $rows[$key_row][$key_cell] = mb_convert_encoding($cell,'UTF-16LE','UTF-8');
// iconv('UTF-8',$rows[$key_row][$key_cell]);
// mb_convert_encoding($rows[$key_row][$key_cell],'UTF-8');
}
}
$temp = fopen('php://memory','w');
foreach($rows as $row) {
fputcsv($temp,$row,';');
}
fseek($temp,0);
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename="test.csv";');
fpassthru($temp);
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)