URL编码 encode

#define CFSTR(cStr)  ((CFStringRef) __builtin___CFStringMakeConstantString ("" cStr ""))




+ (NSString *)encodeURL:(NSString *)string endcode:(NSStringEncoding)stringEncoding

{

NSString *newString = NSMakeCollectable([(NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)string, NULL, CFSTR(":/?#[]@!$ &'()*+,;=\"<>%{}|\\^~`"), CFStringConvertNSStringEncodingToEncoding(stringEncoding)) autorelease]);

if (newString) {

return newString;

}

    

return @"";

}

上一篇:浅解前端必须掌握的算法(一):冒泡排序


下一篇:Web前端 — Bootstrap(5)