如何从xcode中的string解码HTML实体(“
”和“£”)
在XML数据是
<content_special> SAT 17TH TEST test club cheap drinks £3 shots £5 bottles $beers </content_special>
我得到这个string使用这个代码
TBXMLElement *Content_Special=[TBXML childElementNamed:@"content_special" parentElement:Club]; NSString *Content_SpecialStr = [TBXML textForElement:Content_Special];
当我NSLog(@"Content_special:%@",Content_SpecialStr);
这样的打印
Content_special:SAT 17TH TEST
test club
cheap drinks
£3 shots
£5 bottles
$beers
我怎么能得到原来的蜇在Xlm显示? 任何build议…
使用Google Toolbox for Macfind解决schemeGTMNSString + HTML.h , GTMNSString + HTML.m和GTMDefines.h ,
首先#import "GTMNSString+HTML.h"
使用像这样: Content_SpecialStr = [Content_SpecialStr gtm_stringByUnescapingFromHTML];
确保您的数据xml文件具有utf-8编码http://www.w3schools.com/xml/xml_encoding.asp