• 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: Str255 Conversion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Str255 Conversion


  • Subject: Re: Str255 Conversion
  • From: "Clark S. Cox III" <email@hidden>
  • Date: Wed, 12 Mar 2003 15:21:27 -0500

On Wednesday, Mar 12, 2003, at 14:12 US/Eastern, Craig Bakalian wrote:

Hi,
I need to convert a Str255 to an NSString. I am using voice
recognition. All is well, except for the Str255. How do I do it? What
exactly is a Str255? I mean, I thought I knew everything :) Thanks in
advance...

A Str255 is an array of 256 unsigned chars, the first of which represents the length of the string (i.e. it's a pascal-style string). If you know for a fact that it doesn't contain any non-ASCII characters:

Str255 somePascalString = "\pMy string";
NSString *nsString = [NSString stringWithCString: (const char*)&somePascalString[1] length: somePascalString[0]];

Or, since CFStrings and NSStrings are identical, you could do something along the lines of (replace kCFStringEncodingMacRoman with the appropriate encoding):

Str255 somePascalString = "\pMy string";
NSString *nsString = [(NSString*)CFStringCreateWithPascalString(NULL, somePascalString, kCFStringEncodingMacRoman) autorelease];




--
http://homepage.mac.com/clarkcox3/
email@hidden
Clark S. Cox, III
_______________________________________________
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: 
 >Str255 Conversion (From: Craig Bakalian <email@hidden>)

  • Prev by Date: RE: What's with 'dark' @implementation?
  • Next by Date: Messaging released object during NIB loading
  • Previous by thread: Str255 Conversion
  • Next by thread: Re: Str255 Conversion
  • Index(es):
    • Date
    • Thread