What is the purpose of the Unicode Character 'BACKSPACE' (U+0008) in programming? What applications can it be used for?
-
4If you cannot determine the purpose for a particular Unicode symbol, it probably goes into the "personal entertainment" category, just like U+2603 and U+1F4A9. :-) – jørgensen Dec 16 '11 at 21:30
-
3There's actually a real purpose for both of those characters: full compatibility with other character sets (both of Japanese origin, in this case!) which include those characters. – Mar 17 '12 at 05:19
1 Answers
On output to a terminal, it typically moves the cursor one position to the left (depending on settings). On input, it typically erases the last entered character (depending on the application and terminal settings), though the DEL / DELETE character is also used for this purpose. Typically it can be entered by pressing Backspace or Control-H
Note that its action of deleting characters occurs only on a display, not in memory. A string within a running program can contain just about any sequence of characters (depending perhaps on the language), including backspace. In that context, it's generally just another character. For example, in C strlen("abcd\b")
is 5, not 3.
In C and a number of other languages, it's represented in program source as '\b'
. It's sometimes displayed as ^H
.
All this applies whether it's represented as Unicode or not. The backspace character is common to most or all character sets: ASCII, Latin-1, the various Unicode representations -- even EBCDIC has a backspace character (but with a different code).

- 11,022
- 8
- 52
- 58

- 254,901
- 44
- 429
- 631
-
So adding \b to a string is more efficient than calling string=substring() or something? Will "this\b" string have a length of 3 or 5? – skibulk Dec 16 '11 at 21:51
-
3`"this\b"` has a length of 5. Adding a backspace character to a string doesn't remove characters from the string. Its action of deleting characters occurs on the display, not in memory. – Keith Thompson Dec 16 '11 at 22:02
-
1Note that when `\b` is written to a printer instead of a screen, it does overstriking instead of deletion. This allowed a primitive way to implement underlining (`A\b_`), boldface (`A\bA`), or accented characters (`n\b~`). – dan04 Dec 21 '11 at 23:15
-
1@dan04: Probably, but I don't know whether support for `\b` on printers is universal. – Keith Thompson Dec 22 '11 at 01:34
-
2Printers that have an ascii mode should support it, since it's part of ASCII. But programs that underline with backspace (such as `man`) usually produced `_\bA`, not `A\b_`. That way, on terminals without overstrike, the letter overwrites the underscore and not the other way around. – alexis Jun 27 '13 at 19:18
-
1@KeithThompson, This doesn't explain why the backspace character was invented in the first place..... – Pacerier May 14 '14 at 20:50
-
-
1
-
@Pacerier: I tried to explain that in my answer. What was unclear? – Keith Thompson May 14 '14 at 21:09
-
@KeithThompson, You said that it typically erase the last entered character. Why not just remove the last character then, instead of *adding* a backspace char? – Pacerier May 14 '14 at 21:22
-
@Pacerier: What I said was that *input* of a backspace character typically causes the previous character to be erased (you can see this in line-oriented input and in some text editors). In that context the backspace key is a *command* that causes the program to erase the previous character, and the backspace character itself is not added to anything, just processed and discarded. – Keith Thompson May 14 '14 at 21:25
-
@KeithThompson, So it can be said that the backspace character exists as a *hack* to accomodate *systems* that are incapable of handling input beyond characters. – Pacerier May 18 '14 at 17:04
-
@Pacerier: Yes, it can be said. You just did. I didn't. Feel free to post your own answer. – Keith Thompson May 18 '14 at 19:32
-
@KeithThompson, Ok let me try again: Would you consider the backspace character exists as a *hack* to accomodate *systems* that are incapable of handling input beyond characters? – Pacerier May 18 '14 at 20:25
-
@Pacerier: Not really, no. It's part of the character I/O system, with semantics that can vary a bit from one system to another. Your statement seems to imply that you have some alternative in mind, but you haven't said what it might be. – Keith Thompson May 18 '14 at 22:34
-
@KeithThompson, An alternative would be to have two channels instead. One for *input*, and one for *non-input* (e.g. backspace). – Pacerier May 19 '14 at 15:53
-
@Pacerier: And how would that be handled using a keyboard? Do you have something in mind that would be more convenient for the end user, or do I have to use a separate device to erase the last character I typed? – Keith Thompson May 19 '14 at 16:14
-
@KeithThompson, It will be only one device. Yes, the keyboard will handle two channels, except it can't, presumly because of the existance of this hack. Otherwise keyboards now *will* be able to handle two channels. – Pacerier May 19 '14 at 16:42
-
@Pacerier: I fail to see either how this is better than the current situation, how it's relevant to the question, or how it's relevant to my answer. If you have something to say about the purpose of the backspace character, post your own answer. If you have something to say that's neither a question nor an answer, you should probably find some other place to discuss it. – Keith Thompson May 19 '14 at 17:34