我创建了一个简单的 PHP 脚本作为测试。我想让 PHP 从一些数据中保存一个 csv。这个脚本有效,但是当我在 Excel 中打开它时,特殊字符是乱码。
<!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>Character Test</title>
</head>
<body>
<ul>
<?php
$spanishDept = array('Swimwear'=>'Trajes de baῆo','Boys Swimwear'=>'Trajes de baῆo','Girls Swimwear'=>'Trajes de baῆo','Kids Shoes'=>'Zapatos de niῆos',"Scarves"=>'Paῆoletas','Children\'s'=>'Niῆos','Coffee Mugs'=>'Tasas para café');
$list = '"Item","Spanish"'."\r";
foreach($spanishDept AS $english=>$spanish) {
echo '<li>'.$english.': '.$spanish.'</li>';
$list .= '"'.$english.'","'.$spanish."\"\r";
}
$fp = fopen('theEXCELlist.csv',"w+");
fwrite($fp,$list,strlen($list)+100);
?>
</ul>
</body>
</html>
我可以在 NotePad++ 或 Dreamweaver 中打开它,一切都很好,但在 Excel 中不好