什么是垂直制表符、换页符和退格符?如何在 JavaScript 中使用它们?

发布于 2024-08-23 16:56:47 字数 116 浏览 2 评论 0原文

我想知道什么是垂直制表符、换页符和退格符以及如何在JavaScript中使用它们?或者我有机会(应该)使用它们吗?

I want to know what is vertical tab, form feeds and backspace character and how to use them in JavaScript? Or is there any chance I have to(should) use them?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

々眼睛长脚气 2024-08-30 16:56:47
  • 垂直制表符:\v = U+000b
    • “将表单放置在下一行制表位处。” (在 Safari 上被忽略。)
  • 换页符\f = U+ 000c
    • “在打印机上,加载下一页。在某些终端模拟器中,它会清除屏幕。” (在 Safari 上截断字符串。)
  • 退格键:\b = U+0008
    • “将光标向左移动一位。” (在 Safari 上被忽略。)

这些转义序列的定义可能是因为所有其他 C 派生语言都有它们。一般来说,您不需要使用它们,它们也不会对文本产生有用的影响。

  • Vertical tab: \v = U+000b
    • "Position the form at the next line tab stop." (ignored on Safari.)
  • Form feed: \f = U+000c
    • "On printers, load the next page. In some terminal emulators, it clears the screen." (truncates the string on Safari.)
  • Backspace: \b = U+0008
    • "Move the cursor one position leftwards." (ignored on Safari.)

These escape sequences are defined probably because all other C-derived languages have them. Generally you won't need to use them, nor they will have useful effects on the text.

花桑 2024-08-30 16:56:47

我将尝试通过示例使解释尽可能简单:

\f 或 FormFeed,前进到下一行并省略上一行中的字符数

\r 或 Return Carriage 将转到当前行的开头并打印字符

var myString = "One Two Four\fThree\rKing";

console.log(myString);

输出:

I will try to make the explanation as easy as possible with an example:

\f or FormFeed, with advance to the next line and omit the number of characters in the previous line

\r or Return Carriage will go to the start of the current line and print characters

var myString = "One Two Four\fThree\rKing";

console.log(myString);

Output:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文