user431791 user431791 - 1 year ago 134
iOS Question

How to convert special characters in dictionary to unicode in swift

//temporary dictionary
let tempDict = ["ttTasks":"€ is euro symbol"]

//conversion should replace € symbol with \u20ac

so final dictionary would be

finalDict = ["ttTasks":"\u20ac is euro symbol"]

NOTE: please do not suggest me
as i need to do this for every special character.

Answer Source

Something like this maybe:

for key in tempDict.keys {
    let data = tempDict[key]?.data(using: String.Encoding.nonLossyASCII)
    tempDict[key] = String(data: data!, encoding: String.Encoding.utf8)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download