This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

NSURLResponse Text Encoding VooDoo

By: a guest on Oct 7th, 2010  |  syntax: Objective C  |  size: 0.48 KB  |  views: 141  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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
clone this paste RAW Paste Data