views:

195

answers:

2

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!

A: 

have you tried:

$text = utf8_encode($text);
die($text);

?

Andrei Serdeliuc
i suspect this does not do what you think it does. utf8_encode() turns a Latin-1/ISO-8859-1 string into UTF-8.
Cal
A: 

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 :)

Cal