Skip to content

Instantly share code, notes, and snippets.

@kelp404
Last active October 13, 2015 16:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kelp404/4223222 to your computer and use it in GitHub Desktop.
Save kelp404/4223222 to your computer and use it in GitHub Desktop.
Url Encode

##Url Encode ###Objective-C

#if defined (__GNUC__) && (__GNUC__ >= 4)
#define NYARU_ATTRIBUTES(attr, ...) __attribute__((attr, ##__VA_ARGS__))
#else // defined (__GNUC__) && (__GNUC__ >= 4)
#define NYARU_ATTRIBUTES(attr, ...)
#endif
#define BURST_LINK static __inline__ NYARU_ATTRIBUTES(always_inline)
BURST_LINK NSString *urlEncode(NSString *source)
{
CFStringRef cfstring = CFURLCreateStringByAddingPercentEscapes(NULL, (__bridge CFStringRef) source, NULL, (CFStringRef) @"!*'();:@&=+$,/?%#[]", kCFStringEncodingUTF8);
NSString *result = [NSString stringWithString:(__bridge NSString *)cfstring];
CFRelease(cfstring);
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment