• 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: NSString <--> MacRoman Pascal String
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString <--> MacRoman Pascal String


  • Subject: Re: NSString <--> MacRoman Pascal String
  • From: "Clark S. Cox III" <email@hidden>
  • Date: Fri, 16 May 2003 13:49:06 -0400

On Friday, May 16, 2003, at 13:33 US/Eastern, Uli Kusterer wrote:

Hi,

I have some data that is in MacRoman ("Mac ASCII") encoded Pascal strings. To display and edit them, I need to get them into NSStrings, to later write them out as Pascal Strings again. Sadly, I can't find any NSString method that lets me decode it into a MacRoman string.

The NSString docs say that CFStringRef is interchangeable with NSString everywhere, so I tried:

BOOL NSStringToStr255( NSString* strobj, StringPtr outStr )
{
if( [strobj length] < 256 )
{
Boolean result = false;

StringPtr is just a pointer, so sizeof(outStr) will return 4

result = CFStringGetPascalString( (CFStringRef) strobj, outStr, sizeof(outStr), kCFStringEncodingMacRoman );

return( result == true );
}
else
return NO;
}

Try this:
BOOL NSStringToStr255( NSString* strobj, StringPtr outStr)
{
if( [strobj length] < 256 )
{
return CFStringGetPascalString( (CFStringRef) strobj, outStr, 256, kCFStringEncodingMacRoman );
}
else
return NO;
}

--
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: 
 >NSString <--> MacRoman Pascal String (From: Uli Kusterer <email@hidden>)

  • Prev by Date: Re: [Q] How do I Create an NSEvent Using Runtime Functions?
  • Next by Date: Re: NSString <--> MacRoman Pascal String
  • Previous by thread: NSString <--> MacRoman Pascal String
  • Next by thread: Re: NSString <--> MacRoman Pascal String
  • Index(es):
    • Date
    • Thread