How is a return / enter keypress encoded in a string sent to a SSH shell?

我的未来我决定 提交于 2019-12-23 09:49:40

问题


I am making a SSH client for a special device which does not have a return key on it's keyboard, my question is how is the return key encoded in the string sent to the shell? is it just '\n'?


回答1:


Then Enter key sends the character 13 = \015 = 0x0d = \r = ^M = CR (carriage return). You can observe that by typing Ctrl+V then Enter in a terminal: Ctrl+V tells the shell to insert the next character literally instead of interpreting it as a command.

You can select a different end-of-line character in stty settings, but not all applications will notice. It's better to use the standard character.

For historical reasons, the character sent by the Enter key on keyboards is not the same character that indicates the end of a line in a text file: the end-of-line character is 10 = \012 = 0x0a = \n = ^J = LF (line feed).



来源:https://stackoverflow.com/questions/17393211/how-is-a-return-enter-keypress-encoded-in-a-string-sent-to-a-ssh-shell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!