reading unicode
Posted
by user121196
on Stack Overflow
See other posts from Stack Overflow
or by user121196
Published on 2010-04-20T04:27:25Z
Indexed on
2010/04/20
4:33 UTC
Read the original article
Hit count: 185
I'm using java io to retrieve text from a server that might output character such as é. then output it using System.err, they turn out to be '?'. I am using UTF8 encoding. what's wrong?
int len=0; char[]buffer=new char[1024]; OutputStream os = sock.getOutputStream(); InputStream is = sock.getInputStream(); os.write(query.getBytes("UTF8"));//iso8859_1")); Reader reader = new InputStreamReader(is, Charset.forName("UTF-8")); do{ len = reader.read(buffer); if (len>0) { if(outstring==null)outstring=new StringBuffer(); outstring.append(buffer,0,len); } }while(len>0); System.err.println(outstring);
© Stack Overflow or respective owner