0

I have a PHP API which stores user's name into database. This API is consumed by Android client.

If the text is in English there is no issue storing it.

But if the text is in Marthi/Hindi, it is being stored something like. %E0%A4%85%E0%A4%AE%E0%A5%8B%E0%A4%B2+

When I test the API using Postman (Rest Client) it works fine. The problem is when the request is from Android client.

Request is POST and Content Type:application/json

Update:

Android client is using following code while sending request

//To encode string
public static String encodeStringInUTF16(String stringText) {

    Logger logger = new Logger();
    String utfEncodedString = null;
    try{

        if(StringHelper.isNullOrEmpty(temp)) {
            utfEncodedString = URLEncoder.encode(stringText, "utf-16");
        }else{
            utfEncodedString = stringText;
        }
    }catch (Exception e){
        logger.log(Strings.TAG, "Exception occurred in UTF-16 encoding : " + e);
    }
    return utfEncodedString;
}

//While sending request to API
StringEntity se = new StringEntity(jsonData);
httpost.setEntity(se);
httpost.setHeader("content-type", "application/json");

ResponseHandler<String> responseHandler = new BasicResponseHandler();
logRequest(url, "post", jsonData);
responseString = httpclient.execute(httpost, responseHandler);
logResponse(responseString);
  1. Exactly what am I missing?
  2. Do I need to change server side code or Android Client's code to resolve this issue?

Any help will be appreciated.

Amol Chakane
  • 1,501
  • 2
  • 21
  • 43

1 Answers1

0

Its not your Android Issues. Please check the this post Click Solution

Don't forget to vote answer :)

Community
  • 1
  • 1
divyansh ingle
  • 340
  • 1
  • 9