Re: mySQL; Cocoa; dealing with german special chars
Re: mySQL; Cocoa; dealing with german special chars
- Subject: Re: mySQL; Cocoa; dealing with german special chars
- From: Chris Ridd <email@hidden>
- Date: Wed, 22 May 2002 14:51:30 +0100
Martin Kautz <email@hidden> wrote:
>
Hello list,
>
>
I'm currently playing with the C-API of mySQL to write a small Cocoa
>
driven application, which is getting back a product name for a given
>
order number.
>
>
Well, connecting the server, firing up a query an getting results already
>
works, but I stuck with that german special chars...
>
Until now I'm getting the product names from the database to a *char (c
>
style string) and I wanted to process this string inside Cocoa with the
>
method 'initWithCString:' which lacks german special char support.
It uses the "default" C string encoding, which may or may not (you suggest
not!) support German characters.
>
Does anybody know how to deal with that? Guess, it's in the documentation
>
of NSString, but I'm too stupid to find it...
>
TIA,
>
>
Martin
You need to find out what encoding MySQL is using. But let's say it is
ISO-8859-1 (aka Latin 1). Something like this might work:
NSString *s = [NSString initWithData: [NSData dataWithBytesNoCopy: cs
length: strlen(cs)]
encoding: NSISOLatin1StringEncoding];
You could do something with NSString's
dataUsingEncoding:allowLossyConversion: for going from NSStrings to C
strings.
It is a shame you can't change the C string encoding from the default, it
would potentially save you lots of (calls to the same) conversion code.
Cheers,
Chris
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.