Objective C urlencode urldecode

  • Post author:
  • Post category:IT
  • Post comments:0评论
NSString *urlencode(NSString *str){
	CFStringEncoding cfEncoding = kCFStringEncodingUTF8;
	str = (__bridge NSString *)CFURLCreateStringByAddingPercentEscapes(
		NULL,
		(CFStringRef)str,
		NULL,
		CFSTR("!*'();:@&=+$,/?%#[]"),
		cfEncoding
		);
	return str;
}

NSString *urldecode(NSString *str){
	CFStringEncoding cfEncoding = kCFStringEncodingUTF8;
	str = (__bridge NSString *)CFURLCreateStringByReplacingPercentEscapesUsingEncoding (
		NULL,
		(CFStringRef)str,
		CFSTR(""),
		cfEncoding
		);
	return str;
}

Related posts:

  1. C++成员函数作为pthread_create参数
  2. jQuery延时绑定事件(lazy-bind)
  3. 链接包含”%2F”导致mod_rewrite失效
  4. 史上最强大的PHP MySQL操作类
  5. 消除JavaScript闭包的一般方法

发表评论