1

I am sending a report from a unix shell script that contains chinese characters.

When I open the CSV report in plaintext editor like textmate I can see the chinese characters but when I open CSV report file in Excel I don't see the chinese characters, but some gibberish.

How do I "tell" excel that the file contains Chinese charset ?

Here is the code that sends mail and attaches the CSV file.

send_mail() {

v_mailpart="ZZ_/afg6432dfgkl.94531q"
echo "Mail to be sent to $RPT_SEND_TO"
echo "To: $RPT_SEND_TO
Subject: Blah Report as of $report_date_format;
Content-Type: multipart/mixed; boundary=\"$v_mailpart\"
MIME-Version: 1.0

This is a multi-part message in MIME format.
--$v_mailpart
Content-Type: text/html
Content-Disposition: inline

<html><body><p>Hi All,<p>Please find attached, the daily report <p>Thanks,
<br/>Blah Team</br/><br/><br/></p><p>NOTE: This is an auto-generated email. Do not reply to it. Please send an email to blah-group@mycompany.com in
 case of any issues.<p></body></html>

--$v_mailpart
Content-Transfer-Encoding:UTF-8;
Content-Type: text/plain;charset=\"UTF-8\";
Content-Disposition: attachment; filename=blah-report.csv
`cat $spool_file5`" | /usr/sbin/sendmail -t
}
  • 1
    Try prepending a Byte Order Mark to the original csv. What version of Excel are you using? – cdosborn Mar 14 '16 at 22:35
  • This question might get better results on Super User.  anu: if nothing happens here in the next 48 hours, I suggest that you click "flag" → "in need of moderator intervention" and ask to have the question migrated to Super User.  Please do not just re-ask the same question there. – G-Man Mar 14 '16 at 22:58
  • @cdosborn I am using Excel 2011 for mac. Having a hard time adding BOM to the start. Any Ideas ? – anu Mar 14 '16 at 23:21
  • 1
    Try this { printf '\xEF\xBB\xBF'; cat file; } > file.new – cdosborn Mar 14 '16 at 23:32
  • 1
    What is the output of file yourCsv.csv, before/after the BOM – cdosborn Mar 14 '16 at 23:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.