Re: Representation of strings with special chars
Re: Representation of strings with special chars
- Subject: Re: Representation of strings with special chars
- From: Alexander Reichstadt <email@hidden>
- Date: Thu, 25 Aug 2011 23:03:30 +0200
Hi,
Thank you for your many responses.
> const char *cstr = [s UTF8String];
> mysql_stmt_prepare(myStatement, cstr, strlen(cstr));
This fixed the bug.
Alexander
Am 24.08.2011 um 22:37 schrieb Greg Parker:
> On Aug 24, 2011, at 1:24 PM, Alexander Reichstadt wrote:
>> Actually it's a couple of wrapper-classes to MYSQL c-calls by Karl Kraft.
>>
>> In the sqlfetch-class, eventually it arrives at....
>>
>> mysql_stmt_prepare(myStatement, [s UTF8String],[s length])
>>
>> where s is the NSString instance containing the SELECT-statement, such as SELECT field="someÜberthing".
>>
>> From there it goes on to....
>>
>> int STDCALL mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query,
>> unsigned long length);
>>
>> ....and at this point it fails.
>
> First, [s length] is the wrong value to pass as the length of [s UTF8String]. Try this instead:
> const char *cstr = [s UTF8String];
> mysql_stmt_prepare(myStatement, cstr, strlen(cstr));
>
> Second, this code is sending UTF-8 encoded character data to MySQL. Make sure that your MySQL environment is configured to accept UTF-8 data.
> http://rentzsch.tumblr.com/post/9133498042/howto-use-utf-8-throughout-your-web-stack
> If your MySQL system instead expects some other encoding like ISO Latin-1, you can tell NSString to output that instead.
> [myString cStringUsingEncoding:NSISOLatin1StringEncoding];
>
>
> --
> Greg Parker email@hidden Runtime Wrangler
>
>
_______________________________________________
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