I was trying to convert utf8
to utf8mb4
for a php website, unfortunately, I was success on localhost but failed on test server.
localhost:
- php/5.3.29(brew install php53) or PHP/5.6.8(xampp)
- Apache/2.4.16
test server:
- PHP/5.6.14
- nginx/1.6.0
They are connecting to the same mysql database(encoding: utf8mb4, collation: utf8mb4_unicode_ci).
data tables: (encoding: utf8, collation: utf8_unicode_ci)
some data tables: (encoding: utf8mb4, collation: utf8mb4_unicode_ci)
The php website with CodeIgniter framework current config:
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
With this config, everything is ok. When I change the config to:
$db['default']['char_set'] = 'utf8mb4';
$db['default']['dbcollat'] = 'utf8mb4_general_ci';
everything is ok on my localhost server but not test server.
On test server, the page text which get data from DB show ???
. I try to insert a comment with emoji from page, the comment text is ok.
I use a mysql client Sequel Pro to connect the database, I find the comment that inserted just now is incorrect encoding(windows-1252). PHP save windows-1252 text to a utf8 database.
T_T, please help me. Is that some php extends required?