简体   繁体   English

CakePHP中的非英文字符

[英]Non-English characters in CakePHP

I'm having a problem with CakePHP. 我在CakePHP上遇到问题。 My application is not echoing out any non-English character(ñ,á,é). 我的应用程序没有回显任何非英语字符(ñ,á,é)。 I'm not having that problem with raw PHP but the framework seems to be working odd about the encoding. 我的原始PHP没有这个问题,但是该框架在编码方面似乎工作异常。 I've already tried putting this line in the header of the layout files but it keeps failing: <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> 我已经尝试过将这一行放在布局文件的标题中,但始终失败: <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
Hope you guys can help me out. 希望你们能帮助我。 Thank you. 谢谢。

确保已使用UTF-8编码保存文件。

make sure that your database configuration has the encoding enabled. 确保您的数据库配置已启用编码。

public $default = array(
        'datasource' => 'Database/Mysql',
        'persistent' => false,
        'host' => 'localhost',
        'login' => 'root',
        'password' => '',
        'database' => 'XXX',
        'prefix' => 'XXX_',
        'encoding' => 'utf8',
    );

Where do you get your data from? 您从哪里获得数据? You have to set the correct encoding (utf8?) for your database connection. 您必须为数据库连接设置正确的编码(utf8?)。 If you get input from other sources you can use iconv to convert the data to utf8. 如果您从其他来源获得输入,则可以使用iconv将数据转换为utf8。

http://php.net/manual/de/book.iconv.php http://php.net/manual/de/book.iconv.php

But be aware, that you should know the encoding of your input data, otherwise it is hard or almost impossible to figure your source charset out. 但是请注意,您应该知道输入数据的编码,否则很难或几乎不可能弄清楚源字符集。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM