【问题标题】:iOS decode umlaut &$iOS 解码变音符号 &$
【发布时间】:2012-06-29 07:49:16
【问题描述】:

我有一个我需要解码的例子:

@"für"

如何将其解码为 NSString,使其看起来像

fūr

我尝试了很多方法,包括

[@"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

注意: stringByEncodingHTMLEntities 来自https://github.com/mwaterfall/MWFeedParser/tree/master/Classes stringByDecodingHTMLEntitiesComma 来自 vikingosegundo 的类别。

【问题讨论】:

    标签: ios nsstring decode diacritics


    【解决方案1】:

    试试

    [@"für" stringByDecodingHTMLEntities];
    

    [@"für" gtm_stringByUnescapingFromHTML];
    

    (注意;

    This category 也适用于缺少的;

    【讨论】:

    • 太棒了!谢谢。将使用我使用您的解决方案所做的更新我的原始答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-31
    • 2014-08-25
    • 2013-07-05
    • 2012-01-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多