How to convert string to unicode(UTF-8) string in Swift?

后端 未结 3 1977
终归单人心
终归单人心 2020-12-10 11:48

How to convert string to unicode(UTF-8) string in Swift?

In Objective I could write smth like that:

NSString *str = [[NSString alloc] initWithUTF8Str         


        
3条回答
  •  长情又很酷
    2020-12-10 12:21

    Use this code,

    let str = String(UTF8String: strToDecode.cStringUsingEncoding(NSUTF8StringEncoding))
    

    hope its helpful

提交回复
热议问题