Re: NSString <--> MacRoman Pascal String
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.