i have a webserver setup consisting of Codeigniter, Mysql and Apache.
One a page load i fetch data from a mysql table which looks like:
CREATE TABLE IF NOT EXISTS `names_table` (
`id` integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
....
`name` varchar(180) NOT NULL,
....
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
The data on the serverside is displayed with
echo $this->db->get_where('names_table', array('id' => '6'))->result()->name;
The header of the page served to the client is sent via
header("Content-Type: text/html; charset=UTF-8");
plus i am setting the meta information to
<meta http-equiv="content-type" content="text/html; charset=utf-8">
The PHP file serving the client request is encoded in UTF-8 without BOM, but the name is displayed like Schönefeld although is should be Schönefeld.
The name field with the corresponding id in names_table
has 536368c383c2b66e6566656c64 stored in it.
I spent a few hours searching for possible solutions and i already applied all hints i found so far without working. Thank you very much.
EDIT:
Before displaying the data to the client i run
mb_detect_encoding($name_field);
which says it is UTF-8. I am viewing the page in Chrome where UTF-8 encoding is set, too.
If i understand it correctly, i should not call utf8_decode()
on the variable returned from the database because the browser already understands that the document is in UTF8 and takes appropriate action to decode it, correct?
RESOLVED
As it turns out the data in the table was not imported correctly. I had to use an explicit statement about the character set for it, like here