diff options
author | Max <post@wickenrode.com> | 2016-02-06 00:00:18 +0100 |
---|---|---|
committer | Max <post@wickenrode.com> | 2016-02-07 14:46:32 +0100 |
commit | fc971ed8f4bde8004dc69b4f4e9932e897c80d62 (patch) | |
tree | c3ac79da4a415438b2b769b1b966831ac0a485ca /Frameworks/SPMySQLFramework | |
parent | f4f04bdbeac0580ef8d1b61c5934d1329359ec84 (diff) | |
download | sequelpro-fc971ed8f4bde8004dc69b4f4e9932e897c80d62.tar.gz sequelpro-fc971ed8f4bde8004dc69b4f4e9932e897c80d62.tar.bz2 sequelpro-fc971ed8f4bde8004dc69b4f4e9932e897c80d62.zip |
Add another fallback for charset detection (which might improve compatibility with Sphinx)
Diffstat (limited to 'Frameworks/SPMySQLFramework')
-rw-r--r-- | Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m index 0bfef1a0..3b60e9ef 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m @@ -931,11 +931,28 @@ const char *SPMySQLSSLPermissibleCiphers = "DHE-RSA-AES256-SHA:AES256-SHA:DHE-RS // connection, it may be overridden by init_connect commands or connection state changes. // Default to latin1 for older server versions. NSString *retrievedEncoding = @"latin1"; + // character_set_results is the charset the strings received from the server will be in if ([variables objectForKey:@"character_set_results"]) { retrievedEncoding = [variables objectForKey:@"character_set_results"]; - } else if ([variables objectForKey:@"character_set"]) { + } + // not used in 4.1+ (?) + else if ([variables objectForKey:@"character_set"]) { retrievedEncoding = [variables objectForKey:@"character_set"]; } + // character_set_client is the charset the server expects strings transmitted by us to be in + else if ([variables objectForKey:@"character_set_client"]) { + retrievedEncoding = [variables objectForKey:@"character_set_client"]; // fallback for sphinxql + } + // character_set_connection is used internally by the server for comparisons. + // String literals (without a cast) will always be converted from character_set_client to character_set_connection first. + // As an example: + // * Use a client with "SET NAMES utf8" + // * Do a "set @@session.character_set_connection = 'latin1';" + // * Finally try a "SELECT '犬';" (also try "select _utf8'犬';" for completeness) + // * The result will just show a "?" + // So even though we told the server that the client uses utf8 and the results + // should be encoded in utf8, too, the character got lost. + // This happened because the server did a roundtrip of utf8 -> latin1 -> utf8. // Update instance variables if (encoding) [encoding release]; |