SHARE
TWEET

NSURLResponse Text Encoding VooDoo

a guest Oct 7th, 2010 142 Never
  1. /*
  2.  helper category to get the enum'd NSStringEncoding value from a NSURLResponse
  3.  
  4.  usage: NSStringEncoding encoding = [myResponse textEncodingEnum];
  5. */
  6.  
  7. @interface NSURLResponse (StringEncodingVoodoo)
  8. - (NSStringEncoding) textEncodingEnum;
  9. @end
  10.  
  11. @implementation NSURLResponse (StringEncodingVoodoo)
  12. - (NSStringEncoding) textEncodingEnum
  13. {
  14.         return CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)[self textEncodingName]));
  15. }
  16. @end
RAW Paste Data
Top