I finished the English version of my application and I am currently working on my Arabic application version. Although my English webservices were working fine, there seems to be a problem with my Arabic webservices, I feel that I need to specify the encoding type (utf-8) when I construct my JSON request using the JSONStringer class. Is there a way to do that?
Here is an example of a method that constructs my JSON request,
public static String initLoginJSONRequest(String username, String password){
String parentString = null;
String childString = null;
try{
childString = new JSONStringer()
.object()
.key("username").value(username)
.key("password").value(password)
.endObject()
.toString();
parentString = new JSONStringer()
.object()
.key("UserCredentials").value(childString)
.endObject()
.toString();
}catch(JSONException e){
e.printStackTrace();
}
return parentString;
}
EDIT
I would also like to add that I specify that my encoding is utf-8 in my HttpPost as shown below,
HttpPost post = new HttpPost(getUrl);
StringEntity se = new StringEntity(jsonString);
se.setContentType("application/json;charset=UTF-8");//text/plain;charset=UTF-8
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,"application/json;charset=UTF-8"));
post.setEntity(se);
response = client.execute(post);
But it is not recieving my Arabic charecters on the webservice end (written in .NET) correctly.