Monday, February 4, 2013

Converting string encoding from NSString to NSStringEncoding

Let's say you have to convert encoding from string representation (NSString) to NSStringEncoding. For instance, it happens when you want to get string from response using NSURLConnection. Here is simple solution:

- (NSStringEncoding)encodingStringToNSStringEncoding:(NSString *)encString
    CFStringRef cfEncoding = (__bridge CFStringRef)encString;
    return CFStringConvertEncodingToNSStringEncoding(

No comments:

Post a Comment