anu
anu

Reputation: 1007

How to make excel interpret Chinese characters in CSV file

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 [email protected] 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
}

Upvotes: 0

Views: 4764

Answers (1)

Jim
Jim

Reputation: 385

It is AN encoding problem. A simple work around is open the file using google sheet and save as csv from google sheet.

The Windows Chinese OS use GBK as default Chinese encoding. You should download the Chinese for excel and set the encoding through the Option.

So you should encode it as GBK OR GB18130

  • (1) Download Open Office (free and fast to install, have have higher file size than Cals in Ubuntu).

  • (2) Detect your CSV encoding. Simply open your csv using Open office and choose an encoding method that display your Chinese character.

  • (3) Save your csv to the correct encoding according to your operation system. Default Windows encoding is GBK for Chinese and Ubuntu is UTF8.

Upvotes: 1

Related Questions