diff options
Diffstat (limited to 'Source/CMMCPConnection.m')
-rw-r--r-- | Source/CMMCPConnection.m | 13 |
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 |