Encode URL for WhatsApp “click to chat” without loosing accented characters
I built a form with a textarea to write a message. This form is submitted via Ajax to a PHP script that saves data in database and return an encoded URL to send message via WhatsApp click to chat (
https://wa.me/393301234567?text=this is message's content). I encode URL with
urlencode() PHP function but accented characters (and other special characters) are encoded and in the WhatsApp message that reaches the recipient are illegible.
If I create the link manually using accented characters, the message is sent correctly. How can I encode the URL without also encoding accented characters but only what is strictly necessary (for example spaces)?