以下のコードを使用して、Android から PHP ファイルにアラビア語のテキストを送信しようとしています
Button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
tv = (TextView)findViewById(R.id.from_t);
nv = (TextView)findViewById(R.id.to_t);
rd = (TextView)findViewById(R.id.agent_u);
try {
postData();
}
catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void postData() throws JSONException, UnsupportedEncodingException{
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
String url = "http://XXX.XXX.XXX.XXX/post.php";
HttpPost post = new HttpPost(url);
HttpParams params=post.getParams();
JSONObject json = new JSONObject();
params.setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET, "ISO-8859-1,utf-8;q=0.7,*;q=0.7" );
try {
// JSON data:
json.put("name", tv.getText());
json.put("position",rd.getText());
json.put("position1",nv.getText());
JSONArray postjson=new JSONArray();
postjson.put(json);
post.setEntity(new ByteArrayEntity(json.toString().getBytes("UTF8")));
post.setHeader("Accept-Charset", "UTF-8");
post.setHeader("json",json.toString());
//this is somthing els
System.out.print(json);
HttpResponse response = httpclient.execute(post);
Toast.makeText(getApplicationContext(), "SEND",Toast.LENGTH_SHORT).show();
{
InputStream is = response.getEntity().getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
try {
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
text = sb.toString();
}
}catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
return;
}
}
});
}
コードは問題ありませんが、アラビア語のテキストを送信すると、数字とラテン文字を取得し続けます。助けはありますか?ありがとうございました