• 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: @Strings and strings in C
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: @Strings and strings in C


  • Subject: Re: @Strings and strings in C
  • From: Prachi Gauriar <email@hidden>
  • Date: Sun, 29 Jun 2003 14:20:59 -0500

On Sunday, June 29, 2003, at 09:59 AM, Jeff Harrell wrote:

On Sunday, June 29, 2003, at 07:33 AM, Sanri Parov wrote:

How can I transform a string to a byte string, in order to let it be accepted by BerkeleyDB? To say, converting from @"Hello" to "Hello"?

const char* hello = [@"Hello" cString];

(It works for NSString objects of all sorts, even statically allocated constants as you see here.)

It's worth noting that the cString method could be deprecated soon. Here's what the docs say:

Use of this method is discouraged as it will be deprecated in the near future. Instead it is recommended to use UTF8String to convert arbitrary NSStrings to a lossless 8-bit representation.

Also, if UTF8String won't do it for you for some reason, you can use lossyCString instead, which will convert the string to ASCII with a possible loss of information.

-Prachi
_______________________________________________
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.

  • Follow-Ups:
    • Re: @Strings and strings in C
      • From: Jeff Harrell <email@hidden>
References: 
 >Re: @Strings and strings in C (From: Jeff Harrell <email@hidden>)

  • Prev by Date: [ANN] Backdrop 1.0 released (freeware)
  • Next by Date: Re: @Strings and strings in C
  • Previous by thread: Re: @Strings and strings in C
  • Next by thread: Re: @Strings and strings in C
  • Index(es):
    • Date
    • Thread