yattee/Extensions/String+ReplacingHTMLEntities.swift

15 lines
404 B
Swift
Raw Normal View History

2023-05-26 23:01:17 +00:00
import Foundation
extension String {
var replacingHTMLEntities: String {
do {
return try NSAttributedString(data: Data(utf8), options: [
.documentType: NSAttributedString.DocumentType.html,
.characterEncoding: String.Encoding.utf8.rawValue
], documentAttributes: nil).string
} catch {
return self
}
}
}