Why does PHP store characters such as Japanese in MySQL table that supports utf8 as something else but successfully reads the value back out from MySQL as the original string?
E.g.
$db = new mysqli("localhost", "user", "pwd", "test");
$sql = "INSERT INTO testtable(name) VALUES ('ボーナスエリア');
From workbench this has been inserted into the table as ディション
I have no idea how or at what level that encoding/mapping happens.
Reading it back out in PHP results in the correct string ボーナスエリア
being displayed on the webpage.
Why and how does that work?
UPDATE Thanks for all the comments so far. More than just being curious it actually causes me a problem wanting to insert chars from another source i.e. Java which through jdbc inserts CJK chars correctly. This causes a problem in PHP reading them back out and displaying as ??????
Can anybody prove what encoding translates the characters given into what appears in db viewer?
UPDATE 2 My browser (which has nothing to do with this problem as value is ???? before it displays) is firefox with encoding set to Western ISO-8859-1. I can see Japanese characters display correctly next to ????? characters. Paradoxically, the characters that appear as ???? appear correctly in the db viewer.
Browser Settings
Web page snippet