ipad - objective-c accented characters inside a url request -
ipad - objective-c accented characters inside a url request -
my app connects server asking info php script , shows these info on table. when select row datails shown total text. can read correctly on iphone , ipad display, can modify text , when send php script reads àìùòèé characters not correctly.
the request sent in way
nsmutableurlrequest *richiesta = [nsmutableurlrequest requestwithurl:[nsurl urlwithstring:@"http://www.sito.it/iosphp/trame.php"] cachepolicy:nsurlrequestuseprotocolcachepolicy timeoutinterval:60.0]; [richiesta sethttpmethod:@"post"]; [richiesta sethttpbody:[[nsstring stringwithformat:@"trama=%@", self.trama.text] datausingencoding:nsutf8stringencoding]];
inside database (its collation utf8) see è , other unusual things.
how manage characters correctly?
the default content-type of post application/x-www-form-urlencoded. means need percent encode value sending over.
[[nsstring stringwithformat:@"trama=%@", [self.trama.text stringbyaddingpercentescapesusingencoding:nsutf8stringencoding]]; àìùòèé becomes %c3%a0%c3%ac%c3%b9%c3%b2%c3%a8%c3%a9
objective-c ipad character-encoding
Comments
Post a Comment