views:

53

answers:

0

Hi

I am trying to convert a UTF-8 data to String. The UTF-8 data is obtained by HTTP connection. My problem is the converted String does not display UTF-8 Characters properly.

Here is my code {extra bits removed }

URLConnection urlconn = url.openConnection();
httpConn = (HttpURLConnection) urlconn;
httpConn.connect();
InputStream in= httpConn.getInputStream();
String text = "";
InputStreamReader isr = new InputStreamReader(in,"UTF-8");
int charRead;
char[] inputBuffer = new char[2048];


while((charRead = isr.read(inputBuffer))>0){
String readString = String.copyValueOf(inputBuffer,0,charRead);
text += readString;
inputBuffer = new char[BUFFER];
}

Where am i doing wrong ? The generated text is not UTF-8 !!

Thanks