Re: [xSocket-develop] Telnet and encoding
Status: Inactive
Brought to you by:
grro
|
From: Lo <lo...@ko...> - 2009-08-10 07:12:47
|
Hi,
Thanks. This is some parts of code. I tried to set a "delimiter"
variable changing with the encoding.
* The delimiter variable is used in the onData method like that :
String data = nbConnection.readStringByDelimiter(delimiter);
* The client has an option to change encoding. This one set the encoding
for the client's non blocking connection (nbConnection). :
public void setEncoding(boolean utf8) {
if(utf8) {
nbConnection.setEncoding("UTF-8");
delimiter = "\r\n";
}
else {
nbConnection.setEncoding("ISO-8859-1");
delimiter = "\n";
}
}
* By default on the connection the encoding is ISO-8859-1.
public boolean onConnect(INonBlockingConnection nbc) throws IOException {
nbc.setFlushmode(FlushMode.ASYNC);
nbc.write("Welcome");
nbc.write("\r\n");
nbc.setEncoding("ISO-8859-1");
}
--
Laurent
|