Csv export name uncommon words change Question Mark

Source: Internet
Author: User
Csv export name uncommon words change question mark csv export data
In the user name column, several user names with uncommon characters are changed to "?", The Chinese names of most users are OK,
Iconv ("UTF-8", "GBK", $ username); has no effect on uncommon words before export.
Uncommon words such as "?", "?", "?", "?"


Reply to discussion (solution)

"?", "?", "?", "?" It is not uncommon to say that GBK has already been made.
Ci Hai has more than 10 million words, and GBK has recorded more than 20 thousand points

You specified the GB2312 character set somewhere.

Estimate? Are other character sets used? To.

Csv exported data
In the user name column, several user names with uncommon characters are changed to "?", The Chinese names of most users are OK,
Iconv ("UTF-8", "GBK", $ d-> realname) before export; but has no effect on uncommon words.
Uncommon words such as "?", "?", "?", "?"

Foreach ($ datas as $ d)
{
$ D-> realname = iconv ("UTF-8", "GBK", $ d-> realname );
}
$ Contents = View: make ('user. info_csv ')-> with (compact ('datas '));
$ Response = Response: make ($ contents, 200 );
$ Response-> header ('content-type', 'text/csv; charset = gb2312 ');
$ Response-> header ('content-disposition', 'attachment; filename = "user information .csv "');
Return $ response;

If the problem is found, the exported keyword on the mac server becomes a question mark, and the export is normal in windows.

I don't know how your classes are written. just test it.

Header ("Content-type: text/csv; charset = gb2312"); header ("Content-Disposition: attachment; filename=....csv"); echo '"? ","? ","? ","? "';

No problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.