While parsing I use this code
func encode() -> String{
var newStr = String(utf8String: self.cString(using: .utf8)!)
newStr = newStr!.removingPercentEncoding
guard let data = String(utf8String: self.cString(using: .utf8)!)?.data(using: .utf8) else {
return newStr!
}
guard let attributedString = try? NSAttributedString(data: data, options: [NSAttributedString.DocumentReadingOptionKey.documentType: NSAttributedString.DocumentType.html, NSAttributedString.DocumentReadingOptionKey.characterEncoding: String.Encoding.utf8.rawValue], documentAttributes: nil) else {
return newStr!
}
return attributedString.string
}
the problem is that it removes the \n. So I do not display the text correctly
cStringthere. It's hard to just look at the code. Can you please at least debug it and find after which line the newline is lost?guardstatement withlet data = Data(self.utf8)and replacereturn newStr!withreturn self