问题描述
我正在处理Objective-C中的Urlencoded字符串.是否有实际上可以反转urlENCODING的基础函数?
I'm dealing with an urlencoded string in objective-c. Is there a foundation function that actually reverse the urlENCODING?
收到的字符串类似于:K%FChlschrank,但应在解码Kühlschrank之后
The string received is like: K%FChlschrank but should be after decoding Kühlschrank
推荐答案
Apple已弃用stringByReplacingPercentEscapesUsingEncoding:
从iOS9开始.请使用stringByRemovingPercentEncoding
.
Apple has depreacted stringByReplacingPercentEscapesUsingEncoding:
since iOS9. Please use stringByRemovingPercentEncoding
.
新方法,通过将所有百分比编码的序列替换为匹配的UTF-8字符,返回由接收者生成的新字符串.
The new method, Returns a new string made from the receiver by replacing all percent-encoded sequences with the matching UTF-8 characters.
示例:
NSString *encodedLink = @"hello%20world";
NSString *decodedUrl = [encodedLink stringByRemovingPercentEncoding];
NSLog (@"%@", decodedUrl);
输出:
hello world
这篇关于Objective-C中的urldecode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!