Re: ISO 8859-15 (Latin 9) Euro symbol and more
Re: ISO 8859-15 (Latin 9) Euro symbol and more
- Subject: Re: ISO 8859-15 (Latin 9) Euro symbol and more
- From: Bertrand Mansion <email@hidden>
- Date: Sun, 25 Jul 2004 21:17:17 +0200
Nick Zitzmann wrote:
>
>
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
I considered this solution but are you sure that the function
CFStringConvertEncodingToNSStringEncoding() can be relied upon ?
For example, there is a kCFStringEncodingISOLatin9 in CFStringEncoding but no
equivalent in NSStringEncoding. Will the function result default to something
else than the requested encoding ? I couldn't see any mention of this info in
the documentation.
Bertrand Mansion
Mamasam
http://www.cocoabuilder.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.