问题
During the migration from 2.6 to 3.1 may encounter problems with the display of special characters in the Croatian language. The content is taken from the database.
Content is stored in a database via CakePHP 2.x applications, and can be displayed properly. but when I connect a new application I have a problem with the proper display of these characters čćšđž.
database / tables : 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');
How to fix this?
来源:https://stackoverflow.com/questions/32562023/cakephp-3-1-rc1-utf-8-special-chars-output