简体   繁体   中英

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 the 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);

?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM