libtelnet icon indicating copy to clipboard operation
libtelnet copied to clipboard

fluffos

Open dfbb opened this issue 5 years ago • 8 comments

https://github.com/fluffos/fluffos using libtelnet,

when using OSX telnet client to connect the server, it will strip UTF-8 character High byte to ansi char.

Using Linux/Windows telnet client, everything is fine.

dfbb avatar Jan 13 '21 08:01 dfbb

Make sure your terminal is utf8.

thefallentree avatar Jan 14 '21 04:01 thefallentree

My terminal is Utf8, and BASH LANG=zh_CN.UTF8 It show UTF8 character without problem. the problem is input through libtelnet will be wrong.

dfbb avatar Jan 15 '21 02:01 dfbb

libtelnet does not deal with encodings, it just sends whatever it is received. So it is your telnet client doesn’t send proper utf8 strings, try use iterm2 and possibly try to install telnet from brew instead

thefallentree avatar Jan 15 '21 04:01 thefallentree

it is brew telnet, when using linux telnet , everything is fine.

dfbb avatar Jan 18 '21 02:01 dfbb

it seems that mud server fluffos doesn't do Locale setting.

dfbb avatar Jan 18 '21 02:01 dfbb

https://github.com/seanmiddleditch/libtelnet/issues/25 have same problem

dfbb avatar Jan 18 '21 02:01 dfbb

using nc -v localhost 6666 to connect, it have no utf8 input problem.

dfbb avatar Jan 18 '21 02:01 dfbb

Using telnet client of libtelnet, when I send 2 UTF8 Chinese word "火锅", it send "<0xE7><0x81><0xAB><0xE9><0x94><0x85>", which can be correctly printed as "火锅". Using telnet of Mac to connect to telnet-proxy, when I type the same word, it sends "<0x67><0x01><0x2B><0x69><0x05>", which cannot be printed correctly.

From that #25 example, the binary bytes of UTF-8 of "火锅" are: <1110 0111><1000 0001><1010 1011><1110 1001><1001 0100><1000 0101>

And the binary bytes sent by mac telnet are: <0110 0111><0000 0001><0010 1011><0110 10001>< missing ><0000 0101>

It seems that all the 8th bits are cleared to zero. So it may be related to .inputrc settings. You may set these in ~/.inputrc to enable 8-bit input:

set meta-flag on
set convert-meta off
set input-meta on
set output-meta on

XMLSDK avatar Feb 01 '21 01:02 XMLSDK