Special characters in PHP exported CSV

When creating a CSV file with the special characters, be sure to encounter the problem of encoding characters. Although the output is in UTF-8 OK, Microsoft Excel displays the wrong characters. The solution is simple and is called BOM. At the beginning of the file just add the BOM characters, indicating that the file is in the character set UTF-8.

Solution:

$ document = chr (0xEF). chr (0xBB). chr (0xBF). $ csvContent;

Variable csvContent contains the contents of the CSV document. The variable document is a content of CSV dates, you just need to write to a file.

This entry was posted in PHP. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>