Swift String addingPercentEncoding not working for all special characters

Viewed 1493

This is the string which is further passed as url parameter :

pass@#$%&*?123

I am using this for encoding the characters :

password.text?.addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed) 

This gives me :

pass@%23$%25&*?123

Thus not all characters are encoded using this.
I also tried with urlQueryAllowed, urlPasswordAllowed and other values, but they don't encode all the characters (if you want, I can share the encoded values).
This is the desired string :

pass%40%23%24%25%26*%3F123

What should be used here ?

0 Answers
Related