In Swift, I Decoding HTML using NSAttributedString
, see below:
let encodedString = "Ph?i c?ng nh?n r?ng k? t? lúc ?ng Th?ng?làm b? tr??ng"
let encodedData = encodedString.dataUsingEncoding(NSUTF8StringEncoding)
let attributedOptions = [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType]
let attributedString = NSAttributedString(data: encodedData, options: attributedOptions, documentAttributes: nil, error: nil)
let decodedString = attributedString.string
println(decodedString)
But the result like this:
Pháo£i c?′ng nháo-n ráo±ng ká?? tá?? l?oc ?′ng Th??ng??l??m bá??
tr?°á??ng
The true result must be the same with the encodedString
What's wrong in this method?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…