I can manaully force a CSV file to be detected as UTF-8 by adding a BOM, like so:
file_put_contents($filename, "\xEF\xBB\xBF" . $csv);
Is there a similar thing I can do to force a CSV file to be detected as Shift_JIS?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Shift JIS does not have an equivalent “content type marker” like the BOM. If you output a CSV encoded in Shift JIS, whoever will read that file will have to know it’s in Shift JIS or otherwise detect the encoding.
To create a Shift JIS encoded file, just make sure your
$csvdata is Shift JIS encoded. Convert usingiconvormb_convert_encodingif necessary.