简体   繁体   中英

write unicode character for escape telnet

i'm writing a java code that connects and executes commands in a telnet based equipment. when i login, appears a message like this:

Trying 10.11.115.160...
Connected to 10.11.115.160.
Escape character is '^]'.

the problem is that when i want logout, don't know how to write this char '^]' using a simple string, like this:

telnetClient.execute("^]");

or

telnetClient.execute("\uXXXX");

in a linux terminal, it works using ctrl + ]. i don't found this char in the unicode table.

someone knows? thanks in advance

Ctrl + ] is U+001D INFORMATION SEPARATOR THREE , so it's \ . It can be easily checked by running cat | hexdump cat | hexdump and entering Ctrl + ] , Ctrl + D .

U+001B ESCAPE is Ctrl + [ .

That character is the "group separator", or \ .

^] comes from a somewhat old way of encoding non-printable character for printing. Characters with an ASCII value (yes, this is way far back from the time when ASCII was still relevant) below 32 were encoded by using the ^ character and another ASCII character for the value, taken in sequence starting with @ . Therefore NUL (0) becomes ^@ , character number 1 becomes ^A , 2 becomes ^B etc. GS happens to have the value of 29, and the 29th character after @ in the ASCII table is ] .

Edit: Removed embarassing miscalculation ¬__¬

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM