Default export encoding change to utf-8

[expired user #9459]'s profile image [expired user #9459] posted 8 years ago in Import/Export Permalink
Hello, everybody.

HeidiSQL is the best tool I have ever seen. smile
But now I have encountered some annoying problem.

My native language is Chinese.
The "ANSI" encoding, which is the current default export encoding, will makes my data into mojibake.
I have to change the encoding every time.
If I forgot to change that, I have to reexport my data with correct utf-8 encoding.
May I have some settings to change the default export encoding to utf-8 or remember my last encoding choice automatically?
1 attachment(s):
  • 2015-12-02_093507
ansgar's profile image ansgar posted 8 years ago Permalink
I wonder why Heidi doesn't remember the previous used encoding. Will check that.
ansgar's profile image ansgar posted 8 years ago Permalink
Got it. My comment from r4186 says:

Tweak grid export dialog with some minor enhancements:
- Auto select ANSI encoding for Excel output, see http://en.wikipedia.org/wiki/Comma-separated_values#Application_support
- Auto modify file extension when selecting format
- Support "Include query" checkbox in XML format, see http://www.heidisql.com/forum.php?t=10853#p11082
- Imitate mysqldump's XML style, see http://dev.mysql.com/doc/refman/5.5/en/mysqldump.html#option_mysqldump_xml



Also, many regional versions of Excel will not be able to deal with Unicode in CSV. One simple solution when encountering such difficulties is to change the filename extension from .csv to .txt; then opening the file from an already running Excel instance with the "Open" command, where the user can manually specify the delimiters, encoding, format of columns, etc.



Does your (Chinese?) Excel deal Unicode .csv files correctly when you open such a file by doubleclick?
kalvaro's profile image kalvaro posted 8 years ago Permalink
I have to generate CSV now and then in my PHP scripts and I've found that the Spanish edition of Microsoft Office seems to load UTF-8 files properly if I insert a BOM. It's become my standard solution until ANSI eventually dies (something I expect to happen somewhere around year 2200).
[expired user #9459]'s profile image [expired user #9459] posted 8 years ago Permalink
Ansgar, thanks for your replay.

Sorry, I not a native English speaker, the actually problem is data lost, not mojibake.
I don't use MicroSoft Office, I use Libre Office as an alternative.
When I open csv in Libre Office, I will be ask the encoding setting or use the last choice.

My data has Traditional Chinese and Simplified Chinese in the same table.
Because my Windows is Traditional Chinese, Simplified Chinese transform into ANSI will lost.
I have to export my data in utf-8 encoding.

The kalvaro's solution is a good way.
I have a better idea.
If offer an utf-8 with BOM encoding for Windows and an uft-8 no BOM encoding for UNIX-like system, then remember last encoding choice automatically will be a great choice.

Attachment is "save with encoding" option in Sublime Text 3.
1 attachment(s):
  • 2015-12-02_183530
ansgar's profile image ansgar posted 8 years ago Permalink

You can also just not use Excel CSV output, but Delimited text instead. The difference is, that Excel CSV

  • always exports in ANSI encoding
  • has predefined field delimiter, encloser and line terminator.

Delimited text will remember your previously used encoding. You just need to set the control characters once, so they match to what Libre Office expects.

[expired user #9459]'s profile image [expired user #9459] posted 8 years ago Permalink

I will try this way. Thank you ansgar.

Please login to leave a reply, or register at first.