Это был бы мой подход. Вы можете добавить словарь сущностей из https://gist.github.com/mwaterfall/25b4a6a06dc3309d9555 упоминания Майкла Водопада.
extension String {
func htmlDecoded()->String {
guard (self != "") else { return self }
var newStr = self
let entities = [
""" : "\"",
"&" : "&",
"'" : "'",
"<" : "<",
">" : ">",
]
for (name,value) in entities {
newStr = newStr.stringByReplacingOccurrencesOfString(name, withString: value)
}
return newStr
}
}
Используемые примеры:
let encoded = "this is so "good""
let decoded = encoded.htmlDecoded() // "this is so "good""
ИЛИ
let encoded = "this is so "good"".htmlDecoded() // "this is so "good""