Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > PHP - write a file to disk as ISO-8859-1

PHP - write a file to disk as ISO-8859-1
Thread Tools
Gavin
Mac Elite
Join Date: Oct 2000
Location: Seattle
Status: Offline
Reply With Quote
Jan 27, 2008, 08:42 PM
 
hi, using PHP on a mac webserver

I need to write a file to disk in windows encoding ISO-8859-1 OR UTF 8

It is a CSV file for importing into a windows app. The app chokes on it and I've determined that the Mac server is writing the file in Mac Roman. The app needs ISO-8859-1, and can maybe do UTF8.

My problem is I can't seem to get php to convert the encoding.

I've tried all of these but it always comes out as Mac Roman according to both SubEthaEdit and Text Wrangler.


Code:
$fi['content'] = utf8_encode($fi['content']); OR $fi['content'] = iconv('','UTF-8',$fi['content']); // convert to unicode OR $fi['content'] = iconv("UTF-8","ISO-8859-1",$fi['content']); // convert uft8 to windows latin 1 OR $fi['content'] = iconv('','ISO-8859-1',$fi['content']); // try leaving the input type loose... followed by: $fd = fopen($my_file, 'w'); fwrite($fd, $fi['content']); fclose($fd);
PHP docs say this should work.

What am I missing?

thanks
You can take the dude out of So Cal, but you can't take the dude outta the dude, dude!
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 10:44 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,