bash ANSI 问题:“\x1B[?25h”和“\x1BE”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15011478/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 04:37:40  来源:igfitidea点击:

ANSI questions: "\x1B[?25h" and "\x1BE"

bashshellterminalansi-escape

提问by neubert

  1. What does "\x1B[?25h"do?
  2. How is "\x1BE"different from "\n"? According to http://ascii-table.com/ansi-escape-sequences-vt-100.phpit "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.

  1. 有什么作用"\x1B[?25h"
  2. 如何"\x1BE"不同"\n"?根据http://ascii-table.com/ansi-escape-sequences-vt-100.php它“移动到下一行”?好像那是什么"\n"

    我在 PHP 中尝试过echo "xxx\nxxx\n"echo "xxx\x1BExxx\n"它们都输出相同的内容。

Any ideas?

有任何想法吗?

Thanks!

谢谢!

回答by cmbuckley

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

这些是 ANSI 转义序列(也称为 VT100 代码),是早于 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.

转义序列\x1BEEsc+E是 NEL 或“下一行”,在较旧的终端和大型机上用于表示 CR+LF 或\r\n

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

转义序列\x1B[( Esc+ [) 是控制序列介绍器的一个示例。(\x9B是另一个单字符 CSI。)?25h它后面的控制序列用于显示光标。

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.

大多数终端将支持这些控制代码;要输入转义序列,您可以键入Ctrl+ V, Ctrl+ [,它应该呈现为^[(ESC 的 C0 代码),然后是转义代码。

References:

参考: