From 67bebbe2f9e6222c0a33be77c2d04495026f2437 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Thu, 29 Jul 2010 00:57:11 +0000 Subject: - Add support for automatically converting \r and \r\n linebreaks in query syntax to \n. This addresses Issue #652. - Clean up SPSQLParser, and use a few more CFString methods to avoid obj-c messaging in loops - When importing SQL using autodetect, perform a manual SET NAMES if possible to cope with poorly-exported files. --- Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m') diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m index 56073806..851bf936 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m @@ -1091,6 +1091,58 @@ void performThreadedKeepAlive(void *ptr) return NSISOLatin1StringEncoding; } +/** + * Gets a MySQL charset for the given NSStringEncoding. + * If the NSStringEncoding was not matched, nil is returned. + */ ++ (NSString *) mySQLEncodingForStringEncoding:(NSStringEncoding)stringEncoding +{ + switch (stringEncoding) { + + // Unicode encodings: + case NSUTF8StringEncoding: + return @"utf8"; + case NSUnicodeStringEncoding: + return @"ucs2"; + + // Roman alphabet encodings: + case NSASCIIStringEncoding: + return @"ascii"; + case NSISOLatin1StringEncoding: + case NSWindowsCP1252StringEncoding: + return @"latin1"; + case NSMacOSRomanStringEncoding: + return @"macroman"; + + // Roman alphabet with central/east european additions: + case NSISOLatin2StringEncoding: + return @"latin2"; + case NSWindowsCP1250StringEncoding: + return @"cp1250"; + + // Turkish + case NSWindowsCP1254StringEncoding: + return @"latin5"; + + // Greek: + case NSWindowsCP1253StringEncoding: + return @"greek"; + + // Cyrillic: + case NSWindowsCP1251StringEncoding: + return @"cp1251"; + + // Asian: + case NSJapaneseEUCStringEncoding: + return @"ujis"; + case NSShiftJISStringEncoding: + return @"sjis"; + + default: + return nil; + } +} + /** * Returns the default charset of the library mysqlclient used. */ -- cgit v1.2.3