I just want to make URL with string, and some words contain special character which URL could not parse it ? I use .addingPercentEncoding to encode them, but it give different result. When the string not contain the character such as "é", it will not covert the "_" to "%20".
See the code as below:
let a = "Real_Madrid_CF".addingPercentEncoding(withAllowedCharacters: .urlPathAllowed)!
print(a) // Real%20Madrid%20CF
let b = "Club_Atlético_de_Madrid".addingPercentEncoding(withAllowedCharacters: .urlPathAllowed)!
print(b) // Club_Atl%C3%A9tico_de_Madrid
I don't know the principle on "addingPercentEncoding". Need help!