iphone - display encoded characters like å,ä,ö in UILabel

前端 未结 1 508
醉话见心
醉话见心 2021-01-25 02:13

I have a list that uses UILabel for each of its rows. If I try to display special characters such as å,ä,ö, it displays them as å ä ö How do I convert t

相关标签:
1条回答
  • 2021-01-25 02:56

    The characters display correctly in a WebView because the HTML entities are correctly interpreted by it.

    Maybe this handy NSString category can help you to display the text how you want in a UILabel:

    https://github.com/mwaterfall/MWFeedParser/blob/master/Classes/NSString+HTML.m

    Import both NSString+HTML.h and NSString+HTML.m files, then in your class use

    #import "NSString+HTML.h"
    

    and then you can use

    NSString *decodedString = [encodedString stringByDecodingHTMLEntities];
    

    EDIT :

    You can also try HerbertHansen's solution on the apple dev boards which doesn't need a whole library

    0 讨论(0)
提交回复
热议问题