简体   繁体   中英

Using PHP to write a CSV file with Spanish characters

I have a php script with utf-8 encoding. In it I have an array with special characters (like and n with a ~ on top). It looks just fine in my editor. The php matches the array with text coming in from a html form and writes a csv file. When I write the file I do it like this;

fwrite($fp,utf8_encode($data),strlen($data)+100);

When I open the file it says it is utf-8 encoded but the charters are all messed up.

have you tried without using utf_encode() on the data? it seems that you are reencoding something that's already utf-8 encoded

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