0

i'm using below code to exchange data between android and server but i'm in trouble with sending Persian characters(UTF-8). In server side the received datas looks something like محتوا نامناسب

Code:

HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
        httpURLConnection.setConnectTimeout(10000);
        if (args != null) {
            httpURLConnection.setDoOutput(true);
            httpURLConnection.setRequestMethod("POST");
            String query = args.build().getEncodedQuery();
            OutputStream outputStream = httpURLConnection.getOutputStream();
            BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
            writer.write(query);
            writer.flush();
            writer.close();
            outputStream.close();
        }
Ali Zarei
  • 3,523
  • 5
  • 33
  • 44
  • i think the problem is with server side. they have to decode the string int utf-8 format before insert into database. – Nas Dec 12 '15 at 13:35
  • @Nas so what is solution ? – Ali Zarei Dec 12 '15 at 13:39
  • what type of platform u r using in back end php r .net r someother – Nas Dec 12 '15 at 13:57
  • this [link](http://stackoverflow.com/a/14117250/1790537) may be help u to insert the persian text in correct form – Nas Dec 12 '15 at 14:28
  • @Nas Thanks but not solved and i think the problem is in android code not server , because with old method (Apache library) everything is OK – Ali Zarei Dec 13 '15 at 10:31
  • please post your solution as answer so others can know if they have similar problem. – Nas Dec 13 '15 at 10:52
  • @Nas no buddy , i don't want to use Apache method . my problem and question is still remains – Ali Zarei Dec 13 '15 at 11:57

0 Answers0