• 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; Cocoa; dealing with german special chars
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >mySQL; Cocoa; dealing with german special chars (From: Martin Kautz <email@hidden>)

  • Prev by Date: NSString comparing alphanumerically (with numbers)
  • Next by Date: Re: NSString comparing alphanumerically (with numbers)
  • Previous by thread: mySQL; Cocoa; dealing with german special chars
  • Next by thread: NSString comparing alphanumerically (with numbers)
  • Index(es):
    • Date
    • Thread