title: Swift - Convert HTML text to Attributed String
body: <p>In one of my module, I want show the multiple language HTML texts (English and Tamil) as a NSAttributedString using UILabel. If the text would be pure english, I can show it as my desire <a href="https://stackoverflow.com/questions/28124119/convert-html-to-plain-text-in-swift?utm_medium=organic&amp;utm_source=google_rich_qa&amp;utm_campaign=google_rich_qa">Using this way</a>. But my content has contain both English and Tamil characters. How could I handle this scenario. Kindly share your suggestions, If anyone know about that.</p>
  
  <blockquote>
    <p>HTML Content</p>
  </blockquote>
  
  <pre><code>&lt;medium&gt;&lt;b&gt;&lt;font color='#2f3744'&gt;IPL Tamil Web Series Episode #3 | யாருடா Swetha ? | Tamil Comedy Web Series | Being Thamizhan&lt;/font&gt;&lt;/b&gt;&lt;/medium&gt; has been succesfully scheduled on &lt;medium&gt;&lt;b&gt;&lt;font color='#2f3744'&gt;2018-05-23 08:51 PM&lt;/font&gt;&lt;/b&gt;&lt;/medium&gt;
  </code></pre>
  
  <blockquote>
    <p>Expectation</p>
  </blockquote>
  
  <p><strong>IPL Tamil Web Series Episode #3 | யாருடா Swetha ? | Tamil Comedy Web Series | Being Thamizhan</strong> has been succesfully scheduled on <strong>2018-05-23 08:45 PM</strong></p>
  
  <blockquote>
    <p>Current Output</p>
  </blockquote>
  
  <p><strong>IPL Tamil Web Series Episode #3 | &amp;*$%!@#$@^&amp;$&amp;^%$ Swetha ? | Tamil Comedy Web Series | Being Thamizhan</strong> has been succesfully scheduled on <strong>2018-05-23 08:45 PM</strong></p>
  
  <p>Note: I tried with below code snippet to archive this</p>
  
  <pre><code>extension String {
  var htmlToAttributedString: NSAttributedString? {
      guard let data = data(using: .utf8) else { return NSAttributedString() }
      do {
          return try NSAttributedString(data: data, options:
              [NSAttributedString.DocumentReadingOptionKey.documentType: NSAttributedString.DocumentType.html], documentAttributes: nil)
      } catch {
          return NSAttributedString()
      }
  }
  var htmlToString: String {
      return htmlToAttributedString?.string ?? ""
  }
  }
  </code></pre>