CakePHP 的 UTF-8 输出
我正在尝试将一些 Excel 数据移至 MySQL,但在编码方面遇到问题.
I'm trying to move some Excel-Data to MySQL, but having troubles with encoding.
我做了什么:
- 数据从 OpenOffice 3.1 导出为 csv(utf-8 编码)
- 通过文件上传导入到 phpMyAdmin(表格编码:'utf8_unicode_ci')
- Data export from OpenOffice 3.1 as csv (utf-8 encoded)
- Import to phpMyAdmin via file upload (Table encoding: 'utf8_unicode_ci')
在phpMyAdmin的view模式下,数据显示正确(使用utf-8作为字符集):
In phpMyAdmin's view mode, the data is displayed correctly (it is using utf-8 as charset):
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
当我尝试在我的网页上显示数据时,我得到一个带有问号的哈希值.
When I try to display the Data on my webpage, I get a hash with a question mark in it.
系统信息
- 我尝试在我的页面上使用的语言:德语
- MySQL 客户端版本:5.0.32
- 我的操作系统:MAC OS X 10.5.7
- 服务器脚本:CakePHP v1.2.3.8166
问候,本尼迪克特
推荐答案
我也有类似的症状,我的解决方法是添加
I had a similar symptom, my solution was to add
'encoding' => 'UTF8'
到 config/database.php
to config/database.php
相关文章