Nicos
Nicos

Reputation: 303

Greek encoding in android with HttpClient

i am trying to download a webpage from my android program. But the webpage is greek(), and i only get ??????? in return.

class RequestTask extends AsyncTask<String, String, String>{

    @Override
    protected String doInBackground(String... uri) {
        HttpClient httpclient = new DefaultHttpClient();
        HttpResponse response;
        String responseString = null;
        try {
            response = httpclient.execute(new HttpGet(uri[0]));
            StatusLine statusLine = response.getStatusLine();
            if(statusLine.getStatusCode() == HttpStatus.SC_OK){
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                response.getEntity().writeTo(out);
                out.close();
                responseString = out.toString(); 
            } else{
                //Closes the connection.
                response.getEntity().getContent().close();
                throw new IOException(statusLine.getReasonPhrase());
            }
        } catch (ClientProtocolException e) {
            //TODO Handle problems..
        } catch (IOException e) {
            //TODO Handle problems..
        }
        return responseString;
    }

    @Override
    protected void onPostExecute(String result) {
        super.onPostExecute(result);
        //Do anything with response..
    }
}

The link to the web server is : http://www.cysms.eu/anagram/android/getWR.php

Can you please help me on how to get the greek text correctly?

Regards, Nicos

Upvotes: 0

Views: 195

Answers (1)

eurosecom
eurosecom

Reputation: 2992

Your webservice has charset=Windows-1253 and android expects utf-8, try convert response from win1253 to utf-8

Upvotes: 1

Related Questions