user431791 user431791 - 5 months ago 40
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.


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)