Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

use bytebuffer send Chinese will throw exception.

 
jgm jinggm
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
//use bytebuffer send Chinese whill throw a ioexception.
SocketChannel Channel = null;
StringBuffer m_Buffer = new StringBuffer("中文");
charset = Charset.forName("ISO-8859-1");
encoder = charset.newEncoder();
Channel.write(encoder.encode(CharBuffer.wrap(m_Buffer)));
//this can throw a ioException and message is "Input length = 1"
//what will i do???/
 
jgm jinggm
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is right:
charset = Charset.forName("gb2312");
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic