aboutsummaryrefslogtreecommitdiffstats
path: root/Source/CMMCPConnection.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-06-19 23:02:15 +0000
committerBibiko <bibiko@eva.mpg.de>2009-06-19 23:02:15 +0000
commit4c4c5c22a47417eaa458739d1599c7bb24f75053 (patch)
tree6d0f15daa532684fe215b7fdf0a3ed3219bdf7c1 /Source/CMMCPConnection.m
parent77d8891b8b3dd3321eac871da0bde6fe1f38ea94 (diff)
downloadsequelpro-4c4c5c22a47417eaa458739d1599c7bb24f75053.tar.gz
sequelpro-4c4c5c22a47417eaa458739d1599c7bb24f75053.tar.bz2
sequelpro-4c4c5c22a47417eaa458739d1599c7bb24f75053.zip
• queryString: code cleaning and processing each encoding equally
- Since we are using mysql_real_query() there is no need to generate a \0 terminated cString. - The disadvantage of using UTF8String is that it returns NULL if the encoding fails. - To process each encoding equally we can now use [NSString dataUsingEncoding:enc allowLossyConversion:lossy]. In oder to avoid the overhead while calling it the following inline function is introduced: NSStringDataUsingLossyEncoding(aStr, enc, lossy) := [aStr dataUsingEncoding:enc allowLossyConversion:lossy] • import of CSV: code cleaned and optimized for speed a little
Diffstat (limited to 'Source/CMMCPConnection.m')
-rw-r--r--Source/CMMCPConnection.m13
1 files changed, 3 insertions, 10 deletions
diff --git a/Source/CMMCPConnection.m b/Source/CMMCPConnection.m
index 3101beb9..60b8d2da 100644
--- a/Source/CMMCPConnection.m
+++ b/Source/CMMCPConnection.m
@@ -757,17 +757,10 @@ static void forcePingTimeout(int signalNumber);
(void)(NSString*)(*willQueryStringPtr)(delegate, willQueryStringSEL, query);
// Derive the query string in the correct encoding
- switch(encoding) {
- case NSUTF8StringEncoding:
- theCQuery = NSStringUTF8String(query);
- break;
- default:
- theCQuery = (const char*)(NSString*)(int)(*cStringPtr)(self, cStringSEL, query, encoding);
- //[self cStringFromString:query usingEncoding:encoding];
- }
-
+ NSData *d = NSStringDataUsingLossyEncoding(query, encoding, 1);
+ theCQuery = [d bytes];
// Set the length of the current query
- theCQueryLength = strlen(theCQuery);
+ theCQueryLength = [d length];
// Check query length against max_allowed_packet; if it is larger, the
// query would error, so if max_allowed_packet is editable for the user