title: Encode / Decode string to UTF-8 with Emojis
body: <p>I'm developping a messaging app between Android an iOS (Swift 2.2).</p>
  
  <p>Users must be able to <strong>send and receive Emojis</strong> : <code>Hello </code></p>
  
  <p>I need to encode emojis to <code>UTF-8</code> instead of <code>Unicode</code>.</p>
  
  <p>Here my code to encode / decode from <code>Unicode</code> :</p>
  
  <pre><code>static func decodeUnicode(input: String) -&gt; String {
      let ns = NSString(string: input)
      let data:NSData = ns.dataUsingEncoding(NSUTF8StringEncoding)!
  
      if let decoded = NSString(data:data,encoding:NSUTF8StringEncoding) as? String {
          return decoded
      }
  
      return ""
  }
  
  static func encodeUnicode(input: String) -&gt; String {
      let data:NSData = input.dataUsingEncoding(NSNonLossyASCIIStringEncoding)!
  
      if let decoded = NSString(data:data,encoding:NSUTF8StringEncoding) as? String {
          return decoded
      }
  
      return ""
  }
  </code></pre>
  
  <p>Encoding have to be compatible with Android decoding.</p>