• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Representation of strings with special chars
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Representation of strings with special chars
      • From: Andreas Grosam <email@hidden>
References: 
 >Representation of strings with special chars (From: Alexander Reichstadt <email@hidden>)
 >Re: Representation of strings with special chars (From: Sean McBride <email@hidden>)
 >Re: Representation of strings with special chars (From: Alexander Reichstadt <email@hidden>)
 >Re: Representation of strings with special chars (From: Greg Parker <email@hidden>)
 >Re: Representation of strings with special chars (From: Alexander Reichstadt <email@hidden>)

  • Prev by Date: Re: rightMouseDown: never called in NSView subclass
  • Next by Date: Re: rightMouseDown: never called in NSView subclass
  • Previous by thread: Re: Representation of strings with special chars
  • Next by thread: Re: Representation of strings with special chars
  • Index(es):
    • Date
    • Thread