How to Decode HTML Entities (“
” and “ £”) from string in xcode

六眼飞鱼酱① 提交于 2019-12-02 14:10:19

问题


in xml data is

<content_special>
    SAT 17TH TEST test club cheap drinks £3 shots £5 bottles $beers
</content_special>

i get this string using this code

TBXMLElement *Content_Special=[TBXML childElementNamed:@"content_special" parentElement:Club];
            NSString *Content_SpecialStr = [TBXML textForElement:Content_Special];

when i NSLog(@"Content_special:%@",Content_SpecialStr);

that print like this

 Content_special:SAT 17TH TEST&#13;
test club&#13;
cheap drinks&#13;
&#13;
&#163;3 shots&#13;
&#163;5 bottles&#13;
&#13;
$beers

how can i get original sting which Display in Xlm ? Any suggestion...


回答1:


Found Solution Using Google Toolbox for Mac GTMNSString+HTML.h ,GTMNSString+HTML.m And GTMDefines.h,

First #import "GTMNSString+HTML.h"

use like This: Content_SpecialStr = [Content_SpecialStr gtm_stringByUnescapingFromHTML];




回答2:


Ensure your data xml file has utf-8 encoding http://www.w3schools.com/xml/xml_encoding.asp



来源:https://stackoverflow.com/questions/18549045/how-to-decode-html-entities-13-and-163-from-string-in-xcode

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!