What does an application read when the user press a backspace in the terminal in raw mode?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












In raw mode, if you type a character in the terminal, the application on the other side will read the ASCII code for the typed character.



But what about when you press the backspace key in the terminal, what would the application on the other side read?







share|improve this question


















  • 2




    Why don't you write a program to test it and find out?
    – Stephen Harris
    Nov 5 '17 at 20:55






  • 2




    @StephenHarris Probably because whatever happens on her/his computer is not necessarily universal. E.g. on some systems it might be ^H (0x08) whereas on others DEL (0x7F).
    – egmont
    Nov 5 '17 at 21:32










  • showkey -a ... in a terminal set to send a delete will display 0x7F for backspace... but CTRL backspace will display 0x08 ...
    – RubberStamp
    Nov 5 '17 at 21:36






  • 1




    Possible duplicate of How to allow backspaces in unbuffered/non-canonical mode?
    – JdeBP
    Nov 5 '17 at 22:11










  • @JdeBP This may be a duplicate, but not of that question. Here the question isn't about ^H vs ^? but about what the effect of the backspace key is — “it sends a control character” is the short answer here.
    – Gilles
    Nov 5 '17 at 23:12














up vote
1
down vote

favorite












In raw mode, if you type a character in the terminal, the application on the other side will read the ASCII code for the typed character.



But what about when you press the backspace key in the terminal, what would the application on the other side read?







share|improve this question


















  • 2




    Why don't you write a program to test it and find out?
    – Stephen Harris
    Nov 5 '17 at 20:55






  • 2




    @StephenHarris Probably because whatever happens on her/his computer is not necessarily universal. E.g. on some systems it might be ^H (0x08) whereas on others DEL (0x7F).
    – egmont
    Nov 5 '17 at 21:32










  • showkey -a ... in a terminal set to send a delete will display 0x7F for backspace... but CTRL backspace will display 0x08 ...
    – RubberStamp
    Nov 5 '17 at 21:36






  • 1




    Possible duplicate of How to allow backspaces in unbuffered/non-canonical mode?
    – JdeBP
    Nov 5 '17 at 22:11










  • @JdeBP This may be a duplicate, but not of that question. Here the question isn't about ^H vs ^? but about what the effect of the backspace key is — “it sends a control character” is the short answer here.
    – Gilles
    Nov 5 '17 at 23:12












up vote
1
down vote

favorite









up vote
1
down vote

favorite











In raw mode, if you type a character in the terminal, the application on the other side will read the ASCII code for the typed character.



But what about when you press the backspace key in the terminal, what would the application on the other side read?







share|improve this question














In raw mode, if you type a character in the terminal, the application on the other side will read the ASCII code for the typed character.



But what about when you press the backspace key in the terminal, what would the application on the other side read?









share|improve this question













share|improve this question




share|improve this question








edited Nov 5 '17 at 23:31









Gilles

507k12010031532




507k12010031532










asked Nov 5 '17 at 20:48









user259116

191




191







  • 2




    Why don't you write a program to test it and find out?
    – Stephen Harris
    Nov 5 '17 at 20:55






  • 2




    @StephenHarris Probably because whatever happens on her/his computer is not necessarily universal. E.g. on some systems it might be ^H (0x08) whereas on others DEL (0x7F).
    – egmont
    Nov 5 '17 at 21:32










  • showkey -a ... in a terminal set to send a delete will display 0x7F for backspace... but CTRL backspace will display 0x08 ...
    – RubberStamp
    Nov 5 '17 at 21:36






  • 1




    Possible duplicate of How to allow backspaces in unbuffered/non-canonical mode?
    – JdeBP
    Nov 5 '17 at 22:11










  • @JdeBP This may be a duplicate, but not of that question. Here the question isn't about ^H vs ^? but about what the effect of the backspace key is — “it sends a control character” is the short answer here.
    – Gilles
    Nov 5 '17 at 23:12












  • 2




    Why don't you write a program to test it and find out?
    – Stephen Harris
    Nov 5 '17 at 20:55






  • 2




    @StephenHarris Probably because whatever happens on her/his computer is not necessarily universal. E.g. on some systems it might be ^H (0x08) whereas on others DEL (0x7F).
    – egmont
    Nov 5 '17 at 21:32










  • showkey -a ... in a terminal set to send a delete will display 0x7F for backspace... but CTRL backspace will display 0x08 ...
    – RubberStamp
    Nov 5 '17 at 21:36






  • 1




    Possible duplicate of How to allow backspaces in unbuffered/non-canonical mode?
    – JdeBP
    Nov 5 '17 at 22:11










  • @JdeBP This may be a duplicate, but not of that question. Here the question isn't about ^H vs ^? but about what the effect of the backspace key is — “it sends a control character” is the short answer here.
    – Gilles
    Nov 5 '17 at 23:12







2




2




Why don't you write a program to test it and find out?
– Stephen Harris
Nov 5 '17 at 20:55




Why don't you write a program to test it and find out?
– Stephen Harris
Nov 5 '17 at 20:55




2




2




@StephenHarris Probably because whatever happens on her/his computer is not necessarily universal. E.g. on some systems it might be ^H (0x08) whereas on others DEL (0x7F).
– egmont
Nov 5 '17 at 21:32




@StephenHarris Probably because whatever happens on her/his computer is not necessarily universal. E.g. on some systems it might be ^H (0x08) whereas on others DEL (0x7F).
– egmont
Nov 5 '17 at 21:32












showkey -a ... in a terminal set to send a delete will display 0x7F for backspace... but CTRL backspace will display 0x08 ...
– RubberStamp
Nov 5 '17 at 21:36




showkey -a ... in a terminal set to send a delete will display 0x7F for backspace... but CTRL backspace will display 0x08 ...
– RubberStamp
Nov 5 '17 at 21:36




1




1




Possible duplicate of How to allow backspaces in unbuffered/non-canonical mode?
– JdeBP
Nov 5 '17 at 22:11




Possible duplicate of How to allow backspaces in unbuffered/non-canonical mode?
– JdeBP
Nov 5 '17 at 22:11












@JdeBP This may be a duplicate, but not of that question. Here the question isn't about ^H vs ^? but about what the effect of the backspace key is — “it sends a control character” is the short answer here.
– Gilles
Nov 5 '17 at 23:12




@JdeBP This may be a duplicate, but not of that question. Here the question isn't about ^H vs ^? but about what the effect of the backspace key is — “it sends a control character” is the short answer here.
– Gilles
Nov 5 '17 at 23:12










1 Answer
1






active

oldest

votes

















up vote
2
down vote













Actually, if you type a character in a terminal, the application will read that character.



Well, more precisely, if you type a character in a terminal, it's converted to one or more bytes — most modern Unix system use the UTF-8 encoding of characters. The application reads those bytes and reassembles the characters. This is still not ASCII codes — ASCII is a 7-bit encoding, so all characters in the ASCII character set fit in one byte.



When you type a function or cursor key such as BackSpace, Tab, Return, F1, Left, etc., it's encoded as a control character or an escape sequence. There are a few control characters that correspond to function keys, such as ^I (byte value 9) for Tab and ^M (byte value 13) for Return. Most other function keys send an escape sequence beginning with the escape character (^[, byte value 27).



BackSpace sends a control character. For historical reasons, which control character it sends depends on the terminal and on its configuration: it can be either ^H (byte value 8) or ^? (byte value 127). On many modern terminals, you can change this in the configuration; see How to allow backspaces in unbuffered/non-canonical mode?. In case the setting isn't picked up automatically, you can declare it with stty.



For more background, see How do keyboard input and text output work? and How to make a comprehensive set of possibilities for defining GNU-screen "command characters"?






share|improve this answer






















  • No, stty is not how one changes the terminal's behaviour. See my answer to the duplicate question, where this has already been answered including the correct way, for only some terminals, that one can change what the key sends.
    – JdeBP
    Nov 6 '17 at 7:02










  • stty erase is to tell the line discipline which character is sent by your terminal upon the Backspace key. However, the line discipline doesn't use that information when in raw mode. That information is used to implement the LD's line editor (whereby upon receiving that character, it removes the last character from the line buffer as opposed to adding the ^H/^? to that edit line buffer, and the content of that buffer made available for reading by the application when ^J, eof, eol, eol2 characters are received).
    – Stéphane Chazelas
    Nov 6 '17 at 11:42










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f402720%2fwhat-does-an-application-read-when-the-user-press-a-backspace-in-the-terminal-in%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
down vote













Actually, if you type a character in a terminal, the application will read that character.



Well, more precisely, if you type a character in a terminal, it's converted to one or more bytes — most modern Unix system use the UTF-8 encoding of characters. The application reads those bytes and reassembles the characters. This is still not ASCII codes — ASCII is a 7-bit encoding, so all characters in the ASCII character set fit in one byte.



When you type a function or cursor key such as BackSpace, Tab, Return, F1, Left, etc., it's encoded as a control character or an escape sequence. There are a few control characters that correspond to function keys, such as ^I (byte value 9) for Tab and ^M (byte value 13) for Return. Most other function keys send an escape sequence beginning with the escape character (^[, byte value 27).



BackSpace sends a control character. For historical reasons, which control character it sends depends on the terminal and on its configuration: it can be either ^H (byte value 8) or ^? (byte value 127). On many modern terminals, you can change this in the configuration; see How to allow backspaces in unbuffered/non-canonical mode?. In case the setting isn't picked up automatically, you can declare it with stty.



For more background, see How do keyboard input and text output work? and How to make a comprehensive set of possibilities for defining GNU-screen "command characters"?






share|improve this answer






















  • No, stty is not how one changes the terminal's behaviour. See my answer to the duplicate question, where this has already been answered including the correct way, for only some terminals, that one can change what the key sends.
    – JdeBP
    Nov 6 '17 at 7:02










  • stty erase is to tell the line discipline which character is sent by your terminal upon the Backspace key. However, the line discipline doesn't use that information when in raw mode. That information is used to implement the LD's line editor (whereby upon receiving that character, it removes the last character from the line buffer as opposed to adding the ^H/^? to that edit line buffer, and the content of that buffer made available for reading by the application when ^J, eof, eol, eol2 characters are received).
    – Stéphane Chazelas
    Nov 6 '17 at 11:42














up vote
2
down vote













Actually, if you type a character in a terminal, the application will read that character.



Well, more precisely, if you type a character in a terminal, it's converted to one or more bytes — most modern Unix system use the UTF-8 encoding of characters. The application reads those bytes and reassembles the characters. This is still not ASCII codes — ASCII is a 7-bit encoding, so all characters in the ASCII character set fit in one byte.



When you type a function or cursor key such as BackSpace, Tab, Return, F1, Left, etc., it's encoded as a control character or an escape sequence. There are a few control characters that correspond to function keys, such as ^I (byte value 9) for Tab and ^M (byte value 13) for Return. Most other function keys send an escape sequence beginning with the escape character (^[, byte value 27).



BackSpace sends a control character. For historical reasons, which control character it sends depends on the terminal and on its configuration: it can be either ^H (byte value 8) or ^? (byte value 127). On many modern terminals, you can change this in the configuration; see How to allow backspaces in unbuffered/non-canonical mode?. In case the setting isn't picked up automatically, you can declare it with stty.



For more background, see How do keyboard input and text output work? and How to make a comprehensive set of possibilities for defining GNU-screen "command characters"?






share|improve this answer






















  • No, stty is not how one changes the terminal's behaviour. See my answer to the duplicate question, where this has already been answered including the correct way, for only some terminals, that one can change what the key sends.
    – JdeBP
    Nov 6 '17 at 7:02










  • stty erase is to tell the line discipline which character is sent by your terminal upon the Backspace key. However, the line discipline doesn't use that information when in raw mode. That information is used to implement the LD's line editor (whereby upon receiving that character, it removes the last character from the line buffer as opposed to adding the ^H/^? to that edit line buffer, and the content of that buffer made available for reading by the application when ^J, eof, eol, eol2 characters are received).
    – Stéphane Chazelas
    Nov 6 '17 at 11:42












up vote
2
down vote










up vote
2
down vote









Actually, if you type a character in a terminal, the application will read that character.



Well, more precisely, if you type a character in a terminal, it's converted to one or more bytes — most modern Unix system use the UTF-8 encoding of characters. The application reads those bytes and reassembles the characters. This is still not ASCII codes — ASCII is a 7-bit encoding, so all characters in the ASCII character set fit in one byte.



When you type a function or cursor key such as BackSpace, Tab, Return, F1, Left, etc., it's encoded as a control character or an escape sequence. There are a few control characters that correspond to function keys, such as ^I (byte value 9) for Tab and ^M (byte value 13) for Return. Most other function keys send an escape sequence beginning with the escape character (^[, byte value 27).



BackSpace sends a control character. For historical reasons, which control character it sends depends on the terminal and on its configuration: it can be either ^H (byte value 8) or ^? (byte value 127). On many modern terminals, you can change this in the configuration; see How to allow backspaces in unbuffered/non-canonical mode?. In case the setting isn't picked up automatically, you can declare it with stty.



For more background, see How do keyboard input and text output work? and How to make a comprehensive set of possibilities for defining GNU-screen "command characters"?






share|improve this answer














Actually, if you type a character in a terminal, the application will read that character.



Well, more precisely, if you type a character in a terminal, it's converted to one or more bytes — most modern Unix system use the UTF-8 encoding of characters. The application reads those bytes and reassembles the characters. This is still not ASCII codes — ASCII is a 7-bit encoding, so all characters in the ASCII character set fit in one byte.



When you type a function or cursor key such as BackSpace, Tab, Return, F1, Left, etc., it's encoded as a control character or an escape sequence. There are a few control characters that correspond to function keys, such as ^I (byte value 9) for Tab and ^M (byte value 13) for Return. Most other function keys send an escape sequence beginning with the escape character (^[, byte value 27).



BackSpace sends a control character. For historical reasons, which control character it sends depends on the terminal and on its configuration: it can be either ^H (byte value 8) or ^? (byte value 127). On many modern terminals, you can change this in the configuration; see How to allow backspaces in unbuffered/non-canonical mode?. In case the setting isn't picked up automatically, you can declare it with stty.



For more background, see How do keyboard input and text output work? and How to make a comprehensive set of possibilities for defining GNU-screen "command characters"?







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 6 '17 at 11:26

























answered Nov 5 '17 at 23:30









Gilles

507k12010031532




507k12010031532











  • No, stty is not how one changes the terminal's behaviour. See my answer to the duplicate question, where this has already been answered including the correct way, for only some terminals, that one can change what the key sends.
    – JdeBP
    Nov 6 '17 at 7:02










  • stty erase is to tell the line discipline which character is sent by your terminal upon the Backspace key. However, the line discipline doesn't use that information when in raw mode. That information is used to implement the LD's line editor (whereby upon receiving that character, it removes the last character from the line buffer as opposed to adding the ^H/^? to that edit line buffer, and the content of that buffer made available for reading by the application when ^J, eof, eol, eol2 characters are received).
    – Stéphane Chazelas
    Nov 6 '17 at 11:42
















  • No, stty is not how one changes the terminal's behaviour. See my answer to the duplicate question, where this has already been answered including the correct way, for only some terminals, that one can change what the key sends.
    – JdeBP
    Nov 6 '17 at 7:02










  • stty erase is to tell the line discipline which character is sent by your terminal upon the Backspace key. However, the line discipline doesn't use that information when in raw mode. That information is used to implement the LD's line editor (whereby upon receiving that character, it removes the last character from the line buffer as opposed to adding the ^H/^? to that edit line buffer, and the content of that buffer made available for reading by the application when ^J, eof, eol, eol2 characters are received).
    – Stéphane Chazelas
    Nov 6 '17 at 11:42















No, stty is not how one changes the terminal's behaviour. See my answer to the duplicate question, where this has already been answered including the correct way, for only some terminals, that one can change what the key sends.
– JdeBP
Nov 6 '17 at 7:02




No, stty is not how one changes the terminal's behaviour. See my answer to the duplicate question, where this has already been answered including the correct way, for only some terminals, that one can change what the key sends.
– JdeBP
Nov 6 '17 at 7:02












stty erase is to tell the line discipline which character is sent by your terminal upon the Backspace key. However, the line discipline doesn't use that information when in raw mode. That information is used to implement the LD's line editor (whereby upon receiving that character, it removes the last character from the line buffer as opposed to adding the ^H/^? to that edit line buffer, and the content of that buffer made available for reading by the application when ^J, eof, eol, eol2 characters are received).
– Stéphane Chazelas
Nov 6 '17 at 11:42




stty erase is to tell the line discipline which character is sent by your terminal upon the Backspace key. However, the line discipline doesn't use that information when in raw mode. That information is used to implement the LD's line editor (whereby upon receiving that character, it removes the last character from the line buffer as opposed to adding the ^H/^? to that edit line buffer, and the content of that buffer made available for reading by the application when ^J, eof, eol, eol2 characters are received).
– Stéphane Chazelas
Nov 6 '17 at 11:42

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f402720%2fwhat-does-an-application-read-when-the-user-press-a-backspace-in-the-terminal-in%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?