Can’t convert encoding from us-ascii to utf-8. What am screwing up

encodingutf-8

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?

Best Answer

A file using only plain ASCII characters is indistinguishable from UTF8, as by definition the 7-bit ASCII characters are mapped 1-to-1 in UTF8. Hence your "conversion" doesn't do anything.

Related Question