ios - String encoding for all iPhone standard keyboard characters -


i trying encode string (to send through http post request) accept characters can typed on iphone.

the following works characters try on typical english desktop keyboard

let userpassword = "password1" let encodedpassword = userpassword.stringbyaddingpercentencodingwithallowedcharacters(nscharacterset.alphanumericcharacterset()) 

but doesn't recognize accented characters á, é, í, ó, ú, ü, ñ etc. (that accessible on standard iphone keyboard pressing , holding a, e, i...). there nscharacterset or simple extension include any/all characters found on standard iphone keyboard?

edit: here code request making

let username = "joe" let password = "pássword" let encodedusername = username.stringbyaddingpercentencodingwithallowedcharacters(nscharacterset.alphanumericcharacterset()) let encodedpassword = password.stringbyaddingpercentencodingwithallowedcharacters(nscharacterset.alphanumericcharacterset())  let request = nsmutableurlrequest(url: nsurl(string: "https://www.url.com")!) request.httpmethod = "post" let poststring = "id="+encodedusername+"&pw="+encodedpassword request.httpbody = poststring.datausingencoding(nsutf8stringencoding, allowlossyconversion: false) let task = nsurlsession.sharedsession().datataskwithrequest(request) {         data, response, error in     ... 

just add while taking user input,this way there no chance of user add special symbol or accented characters , don't have encode allowed characters:-

#define acceptable_characters @"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789_."  - (bool)textfield:(uitextfield *)textfield shouldchangecharactersinrange:(nsrange)range replacementstring:(nsstring *)string {          nscharacterset *acceptedinput = [nscharacterset charactersetwithcharactersinstring:acceptable_characters];         if (![[string componentsseparatedbycharactersinset:acceptedinput] count] > 1){             nslog(@"not allowed");             return no;         }         else{             return yes;         } } 

Comments