TwitterApi json doesn't accept arabic and other languages

82 views Asked by At

Hello I'm working on a Twitter client and when I compose a tweet and post it in arabic or japanese It doesn't accept it. why ?

That's method to post a tweet :

public void postTweet(String body, AsyncHttpResponseHandler handler) {
    Log.i(CLASS, "statuses/update.json");
    String apiUrl = getApiUrl("statuses/update.json");
    RequestParams params = new RequestParams();
    params.put("status", body);
    getClient().post(apiUrl, params, handler);
}

and that's after clicking on send button :

  send.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            TwitterClient client = RestApplication.getRestClient();
            client.postTweet(tweet.getText().toString(), new AsyncHttpResponseHandler() {
                @Override
                public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                    Toast.makeText(getActivity(), "Sent Successfully", Toast.LENGTH_LONG).show();
                    dismiss();
                }

                @Override
                public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                    Log.e(CLASS, "Error sending the tweet. Status: " + statusCode, error);
                    Toast.makeText(getActivity(), "Error sending the tweet, please try again.", Toast.LENGTH_LONG).show();
                }
            });
        }
    });

any help please

1

There are 1 answers

1
l3est On

You should specify charset for it :

try this :

ContentType.create("application/json", CharSet.forName("UTF-8"));