• 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: Will Mason <email@hidden>
  • Date: Tue, 11 Jan 2005 08:08:18 -0800 (PST)
  • Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys

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: Robin Hermann <email@hidden>
References: 
 >Re: MySQL Escaped String (From: Robin Hermann <email@hidden>)

  • Prev by Date: Re: nsusername localized?
  • Next by Date: NSCell with NSImage and text
  • Previous by thread: Re: MySQL Escaped String
  • Next by thread: Re: MySQL Escaped String
  • Index(es):
    • Date
    • Thread