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(
CFStringConvertIANACharSetNameToEncoding(cfEncoding));
}
No comments:
Post a Comment