You don't need the NSMutableData:

NSString *str = [[[NSString alloc] initWithBytes:s length:len encoding:NSUTF8StringEncoding] autorelease];

...assuming it's really UTF-8. If it's wchar_t and you know it's Unicode, use NSUTF32StringEncoding (only available on 10.5 or later). If it's UTF-16, use stringWithCharacters:length:.

Deborah Goldsmith
Apple Inc.
[EMAIL PROTECTED]

On Mar 3, 2008, at 11:44 PM, Stuart Malin wrote:

Yes - thanks - that works:

NSMutableData *data = [NSMutableData dataWithBytes:(void *)s length:len];
        //append a NULL unicode char
        XML_Char nullChar = 0;
        XML_Char *nullCharPtr = &nullChar;
        int nullCharLen = sizeof nullChar;
        [data appendBytes:nullCharPtr length:nullCharLen];
NSString *str = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to