##Url Encode ###Objective-C
Last active
October 13, 2015 16:27
-
-
Save kelp404/4223222 to your computer and use it in GitHub Desktop.
Url Encode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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