On the server of my client, when I browse the application, the characters are wrong, because all of the Browsers (Firefox, Chrome, IE) decode the page as ISO-8859-1 instead of UTF-8. Local works great, and on my server works fine too.
I have an application developed with cakePHP 1.3.12:
meta http-equiv="Content-Type" content="text/html; charset=UTF-8"In core.php
Configure::write('App.encoding', 'UTF-8');
In database.php
var $default = array(
'driver' => 'mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'aaa',
'password' => 'aaa',
'database' => 'aaa',
'prefix' => 'app_',
'encoding' => 'utf8'
);
The database, tables and fields collation is utf8_unicode_ci
I also put on the beginning of bootstrap.php:
echo mb_internal_encoding();
...and returns ISO-8859-1, so I put...
mb_internal_encoding('UTF-8');
...but nothing change.
The server that work bad has PHP 5.2.16. I think it's a module or option on the client server, because local and in my server works fine.
Any idea is appreciated.
I solved the problem by putting in the first line of app/config/bootstrap.php file:
header('Content-Type: text/html; charset=utf-8');
Simple and it even seems obvious, but in this hosting, the cakePHP application did not work as expected. The response header always answer Content-Type ISO-8859-1. Now with this change, it answered UTF-8.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With