我有一个MySQL数据库和整理latin1_swidish_ci。我有2个问题。MySQL和PHPExcel中的UTF8字符问题
- 当我回应它时,三角形等奇怪的字符出现在我的网页中。
- 当我使用PHPEXCEL将数据导出到Excel文件时,像é这样的字符未被填充到单元格中。 é后的所有字符都将从字符串中删除!
导出脚本:
header('Content-Type: application/vnd.ms-excel');
header("Content-Disposition: attachment; filename=\"$filename\"");
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
的问题只发生在服务器!它在我的Localhost中工作得很好。请建议。
您需要确保存储在单元格中的所有字符串值都是UTF-8字符串;如果您的数据库以其他字符集存储值,则需要使用[iconv()](http://www.php.net/manual/en/function.iconv.php)或[mb_convert_encoding()]( http://www.php.net/manual/en/function.mb-convert-encoding.php)首先将它们转换为UTF-8 –