On Dec 1, 2011, at 12:19 AM, Claude Saelens wrote:

>       NSMutableString *aNSString = [NSMutableString 
> stringWithString:xmlString];
>       CFStringRef aCFString;
>       CFStringRef bCFString;
>       aCFString = CFStringCreateWithCString(NULL, [aNSString UTF8String], 
> NSUTF8StringEncoding);

“NSUTF8StringEncoding” is wrong here — you’re passing it to a CF function, 
which for some reason has its own different set of constants for string 
encodings, so you’re telling it the wrong encoding. It should be 
kCFStringEncodingUTF8.

Except actually you don’t need these lines at all. It looks like you’re trying 
to convert an NSString to a CFString through a whole bunch of conversions; but 
all this takes is a simple cast:

        CFStringRef aCFString = (CFStringRef) xmlString;

And vice versa, converting CF to NS basically just takes a cast, but you want 
to (a) inform the garbage collector if any that you’re doing this, and (b) 
autorelease the string so it won’t be leaked:

        NSString* returnValue = [NSMakeCollectable(bCFString) autorelease];

—Jens_______________________________________________

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 arch...@mail-archive.com

Reply via email to