title: Convert JSON string UTF8 to NSDictionary Swift
body: <p>I want convert from JSON string to NSDictionary and data is UTF8.
  This is my code:</p>
  
  <pre><code>    override func viewDidLoad() {
      super.viewDidLoad()
      let string = "{\"name\":\"Việt NAM\",\"data\":{\"capital\":\"HÀ NỘI\",\"continents\":\"Châu Á\"}}"
      let dataResult = convertStringToDictionary(text: string)
      print (dataResult)
  }
  
  
  
  func convertStringToDictionary(text: String) -&gt; [String:AnyObject]? {
      if let data = text.data(using: String.Encoding.utf8) {
          do {
              return try JSONSerialization.jsonObject(with: data, options: []) as? [String:AnyObject]
          } catch let error as NSError {
              print(error)
          }
      }
      return nil
  }
  </code></pre>
  
  <p>And data print:</p>
  
  <pre><code>Optional(["name": Việt NAM, "data": {
  capital = "H\U00c0 N\U1ed8I";
  continents = "Ch\U00e2u \U00c1";}])
  </code></pre>
  
  <p>Data in AnyObject is not UTF8.</p>