Home > Mobile >  The android client json Chinese garbled
The android client json Chinese garbled

Time:10-29

Novice, do not know how to describe, is a bit messy, embarrassed,

Android using json in client-side and server-side garbled words in Chinese, the server-side debugging, has shown correctly in Chinese, but to the client or Chinese garbled, is in Chinese???????
no.The HTML code is as follows, only put up part of the code


Protected void onCreate (Bundle savedInstanceState) {

List=new ArrayList (a);
Gv=(the GridView) the findViewById (R.i d.s uyuan_gridview);
MyAdapter=new myAdapter ();
Gv. SetAdapter (myAdapter);

Intent Intent=getIntent ();
Bundle Bundle=intent. GetExtras ();
No=bundle. Get string (" STR ");

}

String doGetShuYuanMsg (String url) {

List List=new ArrayList (a);

NameValuePair p=new BasicNameValuePair (" no, no);

List. Add (p);

String MSG=HttpUtil. DoPost (url, a list);
return msg;

}

The class MyTask extends AsyncTask {

@ Override
Protected void onPostExecute (String result) {
//TODO Auto - generated method stub
Super. OnPostExecute (result);
Gson Gson=new Gson ();
Type Type=new TypeToken () {}. GetType ();
List=gson. FromJson (result, type);
MyAdapter. NotifyDataSetChanged ();
}

}

The class MyAdapter extends BaseAdapter {

@ Override
Public int getCount () {
//TODO Auto - generated method stub
Return the list. The size ();
}

@ Override
Public Object the getItem (int position) {
//TODO Auto - generated method stub
return null;
}

@ Override
Public long getItemId (int position) {
//TODO Auto - generated method stub
return 0;
}


SuYuan s=list. Get (position);
Tv1. SetText (s.g etNo ());
Tv2. SetText (s.g etType ());
Tv3. SetText (s.g etPlace ());
Tv4. SetText (s.g etEnterprise ());
Network tv5 took. SetText (s.g etMaintainer ());
Tv6. SetText (s.g etChecker ());
Tv7. SetText (s.g etGrade ());
Tv8. SetText (s.g etBatch ());
}

CodePudding user response:

HTTP headers set the encoding format, are generally not utf-8, stil are usually results from coding is inconsistent

CodePudding user response:

reference 1st floor gxp1182893781 response:
HTTP headers set the encoding format, are generally utf-8, general gibberish results from inconsistent coding


On the server?

CodePudding user response:

In Android, you wrote before sending HTTP requests, the httpget or httppost set encoding format in the header

CodePudding user response:

Why not use the socket transmission?
  • Related