Re: MySQL Escaped String
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