character encoding - Appropriate charset for Android and Webservices -


i have app retrieves user's data such name, , sends remote database web services. i'm facing issues special accents in name 'tağıyeva'

the name stored ta?ıyeva in db.

this use send data

static string postdata(list<namevaluepair> namevaluepairs, string url) {         inputstream ips = null;         try {             httpconnectionparams.setconnectiontimeout(httpparameters, timeoutconnection);              httpconnectionparams.setsotimeout(httpparameters, timeoutsocket);             defaulthttpclient httpclient = new defaulthttpclient(httpparameters);             httppost httppost = new httppost(myinternetmanager_class.url+url);             httppost.setentity(new urlencodedformentity(namevaluepairs));             // execute http post request             httpresponse response = httpclient.execute(httppost);             ips = response.getentity().getcontent();             string contentasstring = istostring(ips);             if (myinternetmanager_class.debug) log.e("recu",contentasstring);             if (response.getstatusline().getstatuscode() != 200 || contentasstring.length() == 0) return "-1"; // erreur serveur             else return contentasstring;         }         catch (ioexception e) {             //...         }          {             try {if (ips != null) ips.close();} catch (ioexception e){}         }     } 

as can see, i've let default charset (which 1 it?). server set in utf-8. how fix problem?

update: json receive looks "name":"nh\u00e1\u00ba\u00adt pi\u00e1\u00bb\u00abn ta\u00c4\u009f\u00c4\u00b1yeva" use in order convert inputstream string

static string istostring(inputstream stream) {         scanner s = new scanner(stream, "utf-8").usedelimiter("\\a");         return s.hasnext() ? s.next() : "";     } 

but string not displayed correctly. enter image description here instead of 'nhật piừn tağıyeva' how fix it?

thanks

according these docs, urlencodedformentity constructor you're using defaults iso-8559-1 charset. can (and looks should) pass utf-8 second parameter:

httppost.setentity(new urlencodedformentity(namevaluepairs),"utf-8"); 

Comments

Popular posts from this blog

design - Custom Styling Qt Quick Controls -

Unable to remove the www from url on https using .htaccess -