I'm writing a php script to export MySQL database rows into a .txt file formatted for Adobe InDesign's internal markup.
Exports work, but when I encounter special characters like é or umlauts, I get weird symbols (eg Chloë Hanslip
instead of Chloë Hanslip
). Rather than run a search and replace for every possible weird character, I need a better method.
I've checked that when the text hits the database, it's saved properly - in the database I see the special characters. My export code basically runs some regular expressions to put in the InDesign code tags, and I'm left with the weird symbols. If I just output the text to the browser (rather than prompt for a text file download), it displays properly. When I save the file I use this code:
header("Content-disposition: attachment; filename=test.txt");
header("Content-Type: text/plain; charset=utf-8");
I've tried various combinations of utf8_encode()
and iconv()
to no avail. Can anybody point me in the right direction here?