Download CSV, MS Excel open garbled Solution
MS Office EXCEL opens CSV files by default in ANSI, unicode format (for the old version of this, 2007 seems to have been able to identify the UTF-8 Based on BOM, but 2003 does not work)
The following describes how to use CSV compatibility for different office versions of Excel.
The idea is: Convert your code into a UTF-16LE, add a unicode BOM Header "/xFF/xfe", and finally download, so the downloaded CSV is the unicode format
PHP program example:
$ Str4file = iconv ('utf-8', 'utf-16le', $ content );
// Transcode Small Tail Order (UTF-16) into http://zh.wikipedia.org/wiki/UTF-16 ),
This is the Unicode storage text format used by Microsoft and Linux systems, the Apple system uses the large tail order storage text format, that requires the use of UTF-16BE,
While the BOM header uses Fe FF
$ Str4download = gzencode ("/xFF/xfe". $ str4file); // Add the BOM header to compress the content
Header ('content-type: text/CSV; charset = UTF-16LE ');
Header ("Content-Length:". strlen ($ str4download ));
Header ("content-Disposition: attachment; filename =/" $ filename /"");
Echo $ str4download;
Note:
Unicode-encoded. CSV files may not support ",", and must be separated by "/t" spaces.
This is another article about solving CSV Garbled text, see: http://wangblog.org/2007/12/utf-8unicode.html
Introduction: Relationship between UTF-8, UTF-16 and Unicode
The so-called "UTF-8" "UTF-16" is only a form of Unicode, only a Unicode Character Set.
For more details, refer to Wiki
Http://blog.fengruzhuo.com /? P = 295