如何解码iPhone中的字符串

发布于 2024-09-05 13:43:20 字数 432 浏览 5 评论 0原文

我想解码我的字符串。我使用了解析并从 RSS feed 中获取了一个字符串。在字符串中,不允许使用这些特殊字符 &、<、>在我的应用程序中。在服务器端对这些字符进行编码并将其赋予字符串。所以现在我得到了这样的字符串,

 Actual String : <Tom&Jerry>  (only these characters are not allowed in node data & < >).

 After Encoding:  %3CTom%26Jerry%3E.

但我需要显示该字符串是

                  <Tom&Jerry>

那么我如何解码该字符串。

请帮帮我。

谢谢。

I want to decode my string. I have used parsing and get a string from RSS feed. In a string these special characters are not allowed &,<,> in my app. In server side encoding those characters and give it to the string. So now i got the string like,

 Actual String : <Tom&Jerry>  (only these characters are not allowed in node data & < >).

 After Encoding:  %3CTom%26Jerry%3E.

But i need to display the string is

                  <Tom&Jerry>

So how can i decode the string.

Please help me out.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

星軌x 2024-09-12 13:43:20

使用 -stringByReplacingPercentEscapesUsingEncoding: 方法

[@"%3CTom%26Jerry%3E"
 stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

Use the -stringByReplacingPercentEscapesUsingEncoding: method.

[@"%3CTom%26Jerry%3E"
 stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
叶落知秋 2024-09-12 13:43:20

查找

- (NSString *)stringByReplacingPercentEscapesUsingEncoding:(NSStringEncoding)encoding 

Or 通过示例:

NSString *input = @"Hello%20World";
NSString *output = [text stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"%@ becomes %@",input,output);

Log: Hello%20World becomes Hello World

Look for

- (NSString *)stringByReplacingPercentEscapesUsingEncoding:(NSStringEncoding)encoding 

Or by example:

NSString *input = @"Hello%20World";
NSString *output = [text stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"%@ becomes %@",input,output);

Log: Hello%20World becomes Hello World
一笔一画续写前缘 2024-09-12 13:43:20

我得到了答案,我的代码是,

     NSString *currentString =@"%3CTom%26Jerry%3E";

     NSString  * decodeString = [currentString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

    lblTitle.text = decodeString;

谢谢。

I got the answer and my code is,

     NSString *currentString =@"%3CTom%26Jerry%3E";

     NSString  * decodeString = [currentString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

    lblTitle.text = decodeString;

Thanks.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文