Bug in -[NSString stringByAppendingFormat:]?

Nicholas Riley njriley at uiuc.edu
Sat Aug 11 19:00:04 PDT 2001


On Sat, Aug 11, 2001 at 09:54:27PM -0300, Rainer Brockerhoff wrote:
> So... is it a bug, or just unimplemented?

Probably just unimplemented; you should convert the Pascal string to a
C string first, or write a category on NSString to do it.

Or, use a CFString instead:

   NSString* str;
   unsigned char* pstring;

   str = [NSString stringWithCString: "Testing "];
   pstring = "\phi there";

   str = [str stringByAppendingFormat:@":%@",
           CFStringCreateWithPascalStringNoCopy(NULL, pstring, kCFStringEncodingMacRoman, NULL)];

   NSLog(str);

after 'cc -framework Foundation -fpascal-strings main.m' produces:

Aug 11 20:58:36 a.out[636] Testing :hi there

-- 
Nicholas Riley <njriley at uiuc.edu> | <http://www.uiuc.edu/ph/www/njriley>



More information about the MacOSX-dev mailing list