Charset and UTF-8 in a downloaded text file on a Mac
We have a PHP/MYSQL application that collects user input, including special characters like ø,ü,ñ, etc Database is capturing them, and they can be seen via PHPmyAdmin. Download on windows is fine. Display on a mac browser is fine.
When users download t开发者_JAVA技巧he text file on a Mac OSX, the unicode characters come out as other characters. If I save the PHP file as with UTF-8 with BOM, (which apparently affects PHP output) they come out as little black diamonds.
Here is the output header I am using
mb_http_output("UTF-8"); header('Content-type: application/xml; charset="utf-8"'); header("Content-Disposition: attachment; filename=file.xml"); die($text);
Any tips greatly appreciated!
There could be several things wrong, but it sounds like the editor you're opening the file up in on your mac is not recognizing the file as UTF-8, even though it is. Do accented characters appear as two characters each, the first of which is a capital A? That means you're looking at UTF-8 bytes, treated as if they were Latin-1.
It would be easier to know for sure if you could upload the resulting file somewhere :)
have you tried:
$text = utf8_encode($text);
die($text);
?
精彩评论