Re: Representation of strings with special chars
Re: Representation of strings with special chars
- Subject: Re: Representation of strings with special chars
- From: "Glenn L. Austin" <email@hidden>
- Date: Thu, 25 Aug 2011 17:02:32 -0700
On Aug 25, 2011, at 2:03 PM, Alexander Reichstadt wrote:
> Hi,
>
> Thank you for your many responses.
>
>> const char *cstr = [s UTF8String];
>> mysql_stmt_prepare(myStatement, cstr, strlen(cstr));
>
>
> This fixed the bug.
>
> Alexander
Just in case the string has a NULL character, I'd use:
NSData *data = [s dataUsingEncoding:NSUTF8StringEncoding];
mysql_stmt_prepare(myStatement, [data bytes], [data length]);
Of course, if you *did* have a NULL character in your string, then the mysql_stmt_prepare would probably barf at some point. You could use the comparison of strlen() and [data length] to make sure that you're not passing a NULL.
--
Glenn L. Austin, Computer Wizard and Race Car Driver <><
<http://www.austin-soft.com>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden