mtxr / SublimeText-SQLTools

SQLTools for Sublime Text 3
https://code.mteixeira.dev/SublimeText-SQLTools/
GNU General Public License v3.0
177 stars 40 forks source link

Question | Connection Encoding ( CP1252 <- Western Europe ) #162

Closed nemeth-it closed 6 years ago

nemeth-it commented 6 years ago

### DESCRIPTION ### I've old database tables here which are encoded in Western Europe (cp1251). When I execute an query I recognized that all Umlauts and other special character are replaced with an question-mark-charackter "?".

Example Result: T?r, T?r hinten links mit Scharnier Wanted Result: Tür, Tür hinten links mit Scharnier

This is clearly an Encoding-Issue, so I tried to replace the encoding-settings under the connection-templates with "cp1251", also tried "windows-1252" but the results doesn't changed.

What did I wrong? Is "cp1251" or "windows-1252" the wrong encoding-identifier/names or do I've to change the encoding for SQLTools because of our tables somewhere else, too?

### ENVIRONMENT ### MacOS Siera (current), MariaDB via Homebrew (current), SQL Tools (current) SQL-Tools connected to (remote) a test-mySQL-server of our local network

mtxr commented 6 years ago

Could you provide an screenshot example of the output when you run the query on your cli?

Also, an screenshot of the SQLTools result would be great! Than we can eliminate some hypothesis, ok?

Thank you @inovek!

tkopets commented 6 years ago

There might be multiple places where wrong encoding can creep in (multiple mysql connection encoding settings, mysql command output encoding). SQLTools uses python decode method to decode the output of mysql command line. The full list of python encodings listed here: https://docs.python.org/3/library/codecs.html#standard-encodings

I've noticed you refer to "cp1251" and "windows-1252" which are two different encodings. Probably you meant "cp1252"?? Both "cp1251" and "windows-1252" seem to be valid python encodings.

I will try to reproduce your issue.

tkopets commented 6 years ago

I think I have a fix for your problem. Please wait for a new release soon and test it out to see if that fixed your problem. Issue may be related to #158

tkopets commented 6 years ago

In new release, which is going to be released very soon there will be a configurable Connection option called default-character-set, that allows you to specify the encoding of MySQL connection which is recommended to set to utf8mb4 for MySQL 5.5.3 or newer and utf8 for MySQL 5.5.2 or older.

Example:

{
  "connections": {
    "Connection MySQL": {
      "type"    : "mysql",
      "host"    : "127.0.0.1",
      "port"    :  3306,
      "database": "dbname",
      "username": "user",
      "password": "password",
      "default-character-set": "utf8",
      "encoding": "utf-8"
    }
  } 
}
tkopets commented 6 years ago

@inovek The fix via additional connection option default-character-set is already available in new release. Please test and close the issue, if that solves your problem.