Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: ISO 8859-15 (Latin 9) Euro symbol and more
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ISO 8859-15 (Latin 9) Euro symbol and more



On Jul 25, 2004, at 11:45 AM, Bertrand Mansion wrote:

Here is the function I came up with but I don't know Carbon and CF at all so it
might leak or even not function correctly so any input on if I should use
CFRelease or save a CFStringGetBytes() call are welcome :)

I think doing something like this would be much cleaner: (warning - written in Mail, untested)

@implementation NSString (Extensions)

+ (id)stringWithCString:(const char *)string cfEncoding:(CFStringEncoding)encoding
{
return [[[self alloc] initWithCString:string cfEncoding:encoding] autorelease];
}

- (id)initWithData:(NSData *)data cfEncoding:(CFStringEncoding)encoding
{
return [self initWithData:data encoding:CFStringConvertEncodingToNSStringEncoding(encoding)];
}

- (id)initWithCString:(const char *)string cfEncoding:(CFStringEncoding)encoding
{
return [self initWithData:[NSData dataWithBytes:string length:strlen(string)] cfEncoding:encoding];
}

@end

That should give you a lot more flexibility when dealing with different encodings.

Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
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: 
 >Re: ISO 8859-15 (Latin 9) Euro symbol and more (From: Bertrand Mansion <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.