Skip to content

Instantly share code, notes, and snippets.

@haraldmartin
Forked from rsms/NSString+URISafeString.m
Created February 16, 2010 17:35
Show Gist options
  • Save haraldmartin/305716 to your computer and use it in GitHub Desktop.
Save haraldmartin/305716 to your computer and use it in GitHub Desktop.
// cocoa NSString URI encode addition
@interface NSString (HUAdditions)
- (NSString *)URISafeString;
@end
@implementation NSString (HUAdditions)
- (NSString*)URISafeString {
return (NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)self, NULL, CFSTR(":/?#[]@!$ &'()*+,;=\"<>%{}|\\^~`"), CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding));
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment