Swift - Encoding and Decoding String for special characters
<p>Here is my problem : I'm currently developping an app including an instant chat (using FCM).
Every thing works except when i try to send special characters like "é" or emojis. 
The push notification received contains the good string but when the discussion is saved on the server and then reloaded, I can't read them and get UTF8 text like "u00ea" for "ê".
I don't really know a lot about encoding etc. but if you guys could help I would be very happy !</p>

<p>Here is the code i use to send a message :</p>

<pre><code>    func sendMessage(_ completion: @escaping (_ response: String) -&gt; ()) {

    DispatchQueue.global(qos: .userInitiated).async { () -&gt; Void in
        let urlString = //Server adress
        let url = URL(string: urlString)

        var request = URLRequest(url: url!)
        let set = CharacterSet()
        request.httpMethod = "POST"
        let postString = "Message=" + /*String text to send*/
        request.httpBody = postString.data(using: String.Encoding.utf8)

    let task = URLSession.shared.dataTask(with: request, completionHandler: { (data, response, error) in

        })
        task.resume()
    }
}
</code></pre>

<p>Thanks a lot !</p>

<p>PS : I'm new to asking to stackoverflow so don't hesitate to ask for more details</p>

<p><strong>Edit as asked by Rob</strong> : 
I sent the message "test é è".<br>
The other phone received "test é è" via push notification.<br>
When one phone loads discussion from the server where its stored the answer from the server is. </p>

<pre><code>    [{"content":"test u00e9 u00e8","sender":"103","timestamp":"1475491191"}]
</code></pre>

<p>Also I'm not coding the server, but the guy who is is also making an android app which works really fine with special characters.</p>

<p><strong>Edit #2</strong> : I also try this code </p>

<pre><code>    var request = URLRequest(url: url!)
        let set = CharacterSet()
        request.httpMethod = "POST"
        let postString = "Message=" + self.message.addingPercentEncoding(withAllowedCharacters: set)!
        let bytesArray = UTF8Encoding.decode(postString)

        request.httpBody = Data(bytes: UnsafePointer&lt;UInt8&gt;(bytesArray), count: bytesArray.count)
</code></pre>

<p>It does not make any difference.</p>

<p>Thanks a lot for your help guys.</p>