Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Answer

deleted 3 characters in body
Source Link
wLc
  • 1k
  • 13
  • 15
extension String{
 func decodeEnt() -> String{
 let encodedData = self.dataUsingEncoding(NSUTF8StringEncoding)!
 let attributedOptions : [String: AnyObject] = [
 NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,
 NSCharacterEncodingDocumentAttribute: NSUTF8StringEncoding
 ]
 let attributedString = NSAttributedString(data: encodedData, options: attributedOptions, documentAttributes: nil, error: nil)!
 
 return attributedString.string
 }
}
let encodedString = "The Weeknd ‘King Of The Fall’"
let foo = encodedString.decodeEnt() //* The Weeknd ‘King Of The Fall’ */
extension String{
 func decodeEnt() -> String{
 let encodedData = self.dataUsingEncoding(NSUTF8StringEncoding)!
 let attributedOptions : [String: AnyObject] = [
 NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,
 NSCharacterEncodingDocumentAttribute: NSUTF8StringEncoding
 ]
 let attributedString = NSAttributedString(data: encodedData, options: attributedOptions, documentAttributes: nil, error: nil)!
 
 return attributedString.string
 }
}
let encodedString = "The Weeknd ‘King Of The Fall’"
let foo = encodedString.decodeEnt() // The Weeknd ‘King Of The Fall’
extension String{
 func decodeEnt() -> String{
 let encodedData = self.dataUsingEncoding(NSUTF8StringEncoding)!
 let attributedOptions : [String: AnyObject] = [
 NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,
 NSCharacterEncodingDocumentAttribute: NSUTF8StringEncoding
 ]
 let attributedString = NSAttributedString(data: encodedData, options: attributedOptions, documentAttributes: nil, error: nil)!
 
 return attributedString.string
 }
}
let encodedString = "The Weeknd ‘King Of The Fall’"
let foo = encodedString.decodeEnt() /* The Weeknd ‘King Of The Fall’ */
Source Link
wLc
  • 1k
  • 13
  • 15
extension String{
 func decodeEnt() -> String{
 let encodedData = self.dataUsingEncoding(NSUTF8StringEncoding)!
 let attributedOptions : [String: AnyObject] = [
 NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,
 NSCharacterEncodingDocumentAttribute: NSUTF8StringEncoding
 ]
 let attributedString = NSAttributedString(data: encodedData, options: attributedOptions, documentAttributes: nil, error: nil)!
 
 return attributedString.string
 }
}
let encodedString = "The Weeknd ‘King Of The Fall’"
let foo = encodedString.decodeEnt() // The Weeknd ‘King Of The Fall’
lang-swift

AltStyle によって変換されたページ (->オリジナル) /