• 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: MySQL Escaped String
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MySQL Escaped String


  • Subject: Re: MySQL Escaped String
  • From: Robin Hermann <email@hidden>
  • Date: Tue, 11 Jan 2005 18:31:44 +0100

Thanks. My head spins...
I just followed the documentation, which states that cString is or will be deprecated and that I should use UTF8String instead. And so I did ;-)
stringWithCString works fine for me though. Is there a way to catch this kind of thing?


Robin Hermann

On 11 jan 2005, at 17:08, Will Mason wrote:

I think  you have an encoding problem in your code.

- (NSString *)escapeStringWithMySQL:(NSString *)stringToEscape
{
     unsigned long len = [stringToEscape length];
     unsigned long new_len;
     char *new_str;
     const char *str = [stringToEscape UTF8String];

Here you're getting a UTF-8 encoded sequence of bytes. That's good.


new_str = malloc((len*2) + 1); new_len = mysql_escape_string(new_str, str, len); new_str = realloc(new_str, new_len + 1);

NSString *escapedString = [NSString stringWithCString:new_str];

Now, you're claiming that the UTF-8 sequence is actually encoded using the default encoding of whatever system is running the code. You could have a conflict between the two encodings. Why not just continue to claim that the sequence is UTF-8 here? Like:

NSString* escapedString = [NSString stringWithUTF8String: new_str];


return escapedString; }

Will


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: MySQL Escaped String
      • From: Shawn Erickson <email@hidden>
References: 
 >Re: MySQL Escaped String (From: Will Mason <email@hidden>)

  • Prev by Date: Re: Drawing scaled lines
  • Next by Date: Re: MySQL Escaped String
  • Previous by thread: Re: MySQL Escaped String
  • Next by thread: Re: MySQL Escaped String
  • Index(es):
    • Date
    • Thread