2012-06-29 29 views
1

我有什麼,我需要解碼的例子:

@ 「F &#252R」

我怎樣才能得到這個解碼,以一個NSString所以它看起來像

毛皮

我嘗試了數個的包括

[@"f&#252r" stringByDecodingHTMLEntities] > f&#252r 
[@"f&#252r" gtm_stringByUnescapingFromHTML] > f&#252r 

但沒有運氣。

謝謝!基於vikingosegundo的解決方案

NSLog(@"möchte decoded to :  > %@", [@"möchte" stringByEncodingHTMLEntities]); 
    NSLog(@"möchte decoded to: > %@", [@"möchte" stringByDecodingHTMLEntities]); 

    NSLog(@"für decoded to :  > %@", [@"für" stringByEncodingHTMLEntities]); 
    NSLog(@"für decoded to: > %@", [@"für" stringByDecodingHTMLEntities]); 

    NSLog(@"m&#246chte decoded:%@", [@"m&#246chte" stringByDecodingHTMLEntitiesComma]); 
    NSLog(@"f&#252r decoded:%@", [@"f&#252r" stringByDecodingHTMLEntitiesComma]); 

möchte decoded to :  > möchte 
möchte decoded to: > möchte 
für decoded to :  > für 
für decoded to: > für 
m&#246chte decoded:möchte 
f&#252r decoded:für 

UPDATE: stringByEncodingHTMLEntities是從https://github.com/mwaterfall/MWFeedParser/tree/master/Classes stringByDecodingHTMLEntitiesComma是vikingosegundo的類別。

回答

0

嘗試

[@"für" stringByDecodingHTMLEntities]; 

[@"für" gtm_stringByUnescapingFromHTML]; 

(注意;

This category還與人從失蹤;

+0

太棒了!謝謝。將使用您的解決方案完成我原來的答案。 – Zsolt