开发者

Non-English characters in CakePHP

开发者 https://www.devze.com 2023-02-17 03:14 出处:网络
I\'m having a problem with 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

I'm having a problem with 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. 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" />

Hope you guys can help me out. T开发者_StackOverflow中文版hank you.


Make sure you have saved your file with UTF-8 encoding.


Where do you get your data from? You have to set the correct encoding (utf8?) for your database connection. If you get input from other sources you can use iconv to convert the data to utf8.

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.


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',
    );
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号