Escape sequence for deleting next/trailing character?
escaping, ruby
Solution
You aren't actually deleting anything with `\x08` , you are merely overwriting the "a" with a "b".
Imagine the very old days when you used a teletype paper terminal. What you would actually see on the paper is an "a" printed, the teletype would back up one space and then print a "b" over it. All the non-printing ascii codes were invented to control the movement of teletype paper terminals.
That's exactly what the output above does, only the terminal screen does not keep the pixels lit for the previous "a".
The "del" char does not have this special meaning to the basic terminal screen. It might mean something to a program such as an editor or a shell, but to STDOUT it's just another ascii char to print.
The original meaning of "del" is ignore this char as input, see :
http://en.wikipedia.org/wiki/Delete_character
There is nothing I know of that you can put before a char that STDOUT will treat as a signal not to print the next CHAR. However if your output is to a terminal emulation program such as xterm, you can do many things using escape codes to accomplish what you want. See for example:
http://ascii-table.com/ansi-escape-sequences-vt-100.php
The "standard" library for abstracting out all these complex codes is `ncurses`, of which there are a couple ruby interfaces. see
Best gem for working with ncurses and ruby
Problem
Is it possible, in addition to deleting a leading character using `\x08`, to also delete a trailing character? Is there an escape sequence that will delete the next character instead of the previous one? I see that delete is apparently mapped to ASCII 127, which is Hex 7F, but the following code: ``` puts "a\x08b\x7fcd" ``` produces ``` b⌂cd ``` I expected that \x7f would delete the 'c' character following it, but it does not.