xcode 如何在objective c iphone中解码URL?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17039127/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 03:28:39  来源:igfitidea点击:

How to decode URL in objective c iphone?

objective-cxcodeurldecode

提问by zeeshan shaikh

I was wondering if there is a method to decode a string that is in URL

我想知道是否有一种方法可以解码 URL 中的字符串

encoded format?

编码格式?

this is my URL i want to decode it but i dont understand how to do this i tried multiple

这是我的 URL 我想解码它但我不明白如何做到这一点我尝试了多次

ways

方法

http://www.demii.com/demo/dooponz/admin/index.php/chat/new_message/4/1/you/2%2C7

http://www.demii.com/demo/dooponz/admin/index.php/chat/new_message/4/1/you/2%2C7

but didn't get the right response

但没有得到正确的回应

Please anyone can help me out of this,

请任何人都可以帮我解决这个问题,

how can i decode this url i dont need % sign.

我如何解码这个 url 我不需要 % 符号。

Thanks

谢谢

回答by Otium

By using the NSString method -(NSString *)stringByReplacingPercentEscapesUsingEncoding:(NSStringEncoding)encoding

通过使用 NSString 方法 -(NSString *)stringByReplacingPercentEscapesUsingEncoding:(NSStringEncoding)encoding

Ex:

前任:

NSString *unencodedUrlString = [@"http://www.demii.com/demo/dooponz/admin/index.php/chat/new_message/4/1/you/2%2C7" stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

回答by francis lanthier

Here's the not deprecated method : string?By?Removing?Percent?Encoding.

这是不推荐使用的方法:string?By?Removing?Percent?Encoding。

NSString *unencodedUrlString = [yourString string?By?Removing?Percent?Encoding];

NSString *unencodedUrlString = [yourString string?By?Removing?Percent?Encoding];