CSV export name Uncommon character Change question mark

Source: Internet
Author: User
CSV-Exported data
User name This column, there are several users of the name of the rare word has become "?", most of the user's Chinese name is OK,
Iconv ("UTF-8", "GBK", $username), but no effect on uncommon characters.
Uncommon words such as "?", "?", "?", "?"


Reply to discussion (solution)

"?", "?", "?", "?" Since the income is GBK, it is not an uncommon word.
Hanyu da Zidian has more than 100,000 words, GBK only included more than 20,000 points

It's supposed to be somewhere where you specified the character set as GB2312.

Is the use of other character sets?

CSV-Exported data
User name This column, there are several users of the name of the rare word has become "?", most of the user's Chinese name is OK,
Iconv ("UTF-8", "GBK", $d->realname), but no effect on uncommon characters.
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;

Find the problem, Mac machine export encountered uncommon word becomes question mark, Windows export Normal.

I don't know how your classes are written, just a simple test.

Header ("content-type:text/csv;charset=gb2312"); header ("Content-disposition:attachment; Filename= user information. csv "); Echo '"? ","? ","? ","? ";

And there's 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.