ios - stored unreadable text - NSJSONSerialization -
i new objective c. got situation causes me lot of trouble... in app, there textfield people can enter comments , store in server , display them somewhere else. however, of these comments in different languages... e.g. chinese... , returns unreadable strings such "ä½ å¥½" in server. pretty sure server set properly... question is: there standard ways/methods can server recognize foreign text?
many in advance!
the followings codes.
nsmutabledictionary *query = [[nsmutabledictionary alloc] init]; [query setvalue:usercommenttextfield.text forkey:@"comment"]; nsdata *postdata = [nsjsonserialization datawithjsonobject:query options:0 error:null]; // set dictionary json nsmutableurlrequest * req = [nsmutableurlrequest requestwithurl:[nsurl urlwithstring:@"http://testurl"]]; [req sethttpmethod:@"post"]; [req sethttpbody:postdata]; [req setvalue:@"text/html" forhttpheaderfield:@"content-type"]; [req setvalue:[nsstring stringwithformat:@"%ld", (unsigned long)[postdata length]] forhttpheaderfield:@"content-length"]; nsurlconnection *connection = [[nsurlconnection alloc] initwithrequest:req delegate:self];
Comments
Post a Comment