14
  1. What does "\x1B[?25h" do?

  2. How is "\x1BE" different from "\n"? According to http://ascii-table.com/ansi-escape-sequences-vt-100.php it "moves to next line"? Seems like that's what "\n" does?

    I tried echo "xxx\nxxx\n" and echo "xxx\x1BExxx\n" in PHP and they both output the same thing.

Any ideas?

Thanks!

Community
  • 1
  • 1
neubert
  • 15,947
  • 24
  • 120
  • 212

1 Answers1

26

These are ANSI escape sequences (also known as VT100 codes) are an early standardisation of control codes pre-dating ASCII.

The escape sequence \x1BE, or Esc+E, is NEL or "Next line", and is used on older terminals and mainframes to denote CR+LF, or \r\n.

The escape sequence \x1B[ (Esc+[) is an example of a Control Sequence Introducer. (\x9B is another single-character CSI.) The control sequence ?25h following it is used to show the cursor.

Most terminals will support these control codes; to enter escape sequences you can type Ctrl+V, Ctrl+[ which should render as ^[ (the C0 code for ESC), followed by the escape code.

References:

cmbuckley
  • 40,217
  • 9
  • 77
  • 91
  • ANSI **escape sequence** covers either escape sequence and control sequence? I learned two are different things [from](https://en.wikipedia.org/wiki/Escape_sequence#Control_sequences) [wikipedia](https://en.wikipedia.org/wiki/Escape_character#Control_character). CSI seems control sequence conceptually. – rosshjb Aug 18 '20 at 12:51
  • 1
    @jinbeomhong your link talks about the differences between characters rather than sequences - an escape _character_ might be a `\​` which is not a control character. But I would say all control sequences are special cases of [escape sequences](https://en.wikipedia.org/wiki/Escape_sequence). – cmbuckley Aug 18 '20 at 17:02