Computing Magazine

Add Special Characters to CSV Export in PHP

Posted on the 18 May 2012 by Akahgy

Description:

When exporting data to CSV, the special characters are not displayed, as the ending ; is treated as a new column.

Solution:

Check the encoding of the CSV file. Make sure this is utf-8.

However, in some cases this will not work regardless. Make sure you echobefore the last line of export the following string:

echo “\xEF\xBB\xBF”;

 

In other cases the fputcsv(); function of PHP might work, specifying the delimiter and the encoding.


Back to Featured Articles on Logo Paperblog