2
I'm trying to debug garbage characters that my webpages are rendering in foreign languages. I want my createpage.php in utf-8.
me@host:/www/webroot$ file -bi createpage.php
text/x-php; charset=us-ascii
me@host:/www/webroot$ iconv -f us-ascii -t utf-8 createpage.php > createpage_utf8.php
me@host:/www/webroot$ file -bi createpage_utf8.php
text/x-php; charset=us-ascii
I have rwx
permessions on the directory, rw
on the files. I must be blind - what am I screwing up here? Is it because ascii is a subset of utf-8 and my php doesn't have any special characters (just the ini files that I include
), so file -bi
just reports ascii anyway?
Well I feel a little silly. I guess my problem lies with php's PDO module then, since all my tables are encoded in UTF-8. Thanks for taking the time to answer. – Escher – 2015-03-06T14:57:41.520
Make sure that the webserver is passing on that the content is UTF-8 encoded, e.g. by adding a config line
AddDefaultCharset UTF-8
– wurtel – 2015-03-06T15:05:58.350$db->exec("SET CHARACTER SET utf8");
directly after opening the PDO connection to the database may help, withmysql
. – wurtel – 2015-03-06T15:07:32.830All the relevant tables were already utf8 and the webserver was set to utf8, as were the http headers. It turns out I had just forgotten the
charset=utf8
argument when instantiating the PDO object. – Escher – 2015-03-06T15:15:26.537