0
4

2 回答 2

3

I take it you expect to see the following:

“HexTab”

And you see the following instead:

“HexTab�

You're saving the file as UTF-8, but the program reading the file is decoding it using cp1252. These two have to match!

Two options:

  1. Encode the text using cp1252 (:encoding(cp1252)) if the reader is going to continue decoding it using cp1252.
  2. Have the reader decode the file using UTF-8 if you're going to encode it as UTF-8 (:encoding(UTF-8)).

Generally speaking, the latter is the better option as it allows the file to contain any Unicode character rather than an abysmally small subset.

于 2013-10-15T17:45:38.670 回答
1

There a program called iconv on most Unix systems that can re-encode files from one encoding to another. You need to determine the original encoding of your file.

You would run iconv as:

$ iconv -f utf8 -t cp1252 $file_name.csv > $new_file_name.csv

This would translate a file written in Windows using the default Code Page 1252 and convert it into UTF-8 encoding. I would first try cp1252 and see if that works. If not, try cp1250, latin1, and macintosh (It could have been a file created with MacRoman.

See if iconv can get rid of the issue.

于 2013-10-15T17:49:53.433 回答