CakePHP 3.1-rc1 utf-8特殊字符输出

时间:2015-09-14 10:02:04

标签: cakephp utf-8 special-characters cakephp-3.1

在从2.6迁移到3.1期间,可能会遇到克罗地亚语中显示特殊字符的问题。内容取自数据库。

内容通过CakePHP 2.x应用程序存储在数据库中,并且可以正确显示。但是当我连接一个新的应用程序时,我对这些字符的正确显示有问题čćšđž。

数据库/表格:MyISAM utf8_general_ci

cakephp 2.x app

public $default = array(
        'datasource' => 'Database/Mysql',
        'persistent' => false,
        'host' => 'localhost',
        'login' => '*********',
        'password' => '************',
        'database' => 'apartmani',
    );

core.php中

/**
 * Application wide charset encoding
 */
Configure::write('App.encoding', 'UTF-8');

bootstrap.php中

Configure::write('Config.language', 'hrv');

cakephp 3.1- rc1

'App' => [
        'namespace' => 'App',
        'encoding' => 'UTF-8',
...

'Datasources' => [
        'default' => [
            'className' => 'Cake\Database\Connection',
            'driver' => 'Cake\Database\Driver\Mysql',
            'persistent' => false,
            'host' => 'localhost',
            /**
             * CakePHP will use the default DB port based on the driver selected
             * MySQL on MAMP uses port 8889, MAMP users will want to uncomment
             * the following line and set the port accordingly
             */
            //'port' => 'nonstandard_port_number',
            'username' => '*********',
            'password' => '***********',
            'database' => 'apartmani',
            'encoding' => 'utf8',
            'timezone' => 'UTC',
            'cacheMetadata' => true,

bootstap.php

/**
 * Set the default locale. This controls how dates, number and currency is
 * formatted and sets the default language to use for translations.
 */
ini_set('intl.default_locale', 'hr');

如何解决这个问题?

0 个答案:

没有答案