• 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: char Array to NSString to cString?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: char Array to NSString to cString?


  • Subject: Re: char Array to NSString to cString?
  • From: Charles Steinman <email@hidden>
  • Date: Fri, 1 Jun 2007 08:34:40 -0700 (PDT)

This is really a job for NSData. If you can use that, I would. NSString makes no guarantees about how it represents things internally, as far as I know.

Cheers,
Chuck

Vince Ackerman <email@hidden> wrote: I'm having a bit of trouble trying to convert an array of 7 (unsigned
char) to a NSString. I need to pass this array of hex values to
another object that is expecting an NSString that it will convert to
a C string and send it out the serial port using this function:

  -(int)writeString:(NSString *)string
{
 return write(fileDescriptor, [string cString], [string cStringLength]);
}

I need it to write these hex values exactly without any conversion or
encoding. I'm getting a bit lost (as a Newbie) as to how to convert
from an array to NSString then back again to c string since 10.4
deprecates all the cString methods. The methods I've tried seem to be
changing the hex values.

This is an example of hex numbers in myArray:

(unsigned char) myArray[7];

0xff 0x01 0x00 0x02 0x20 0x00 0x23


Can anyone help me understand how to do this?


Thanks in advance,

Vince
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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




---------------------------------
Food fight? Enjoy some healthy debate
in the Yahoo! Answers Food & Drink Q&A.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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

References: 
 >char Array to NSString to cString? (From: Vince Ackerman <email@hidden>)

  • Prev by Date: char Array to NSString to cString?
  • Next by Date: Re: char Array to NSString to cString?
  • Previous by thread: char Array to NSString to cString?
  • Next by thread: Re: char Array to NSString to cString?
  • Index(es):
    • Date
    • Thread