什么是回车,换行和换页? [英] What are carriage return, linefeed, and form feed?

查看:459
本文介绍了什么是回车,换行和换页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下控制字符是什么意思:

What is the meaning of the following control characters:

  1. 回车

  1. Carriage return

换行符

换页

推荐答案

回车表示返回到当前行的开头而不向下移动.该名称来自打印机的托架,因为在创建该名称时很少使用监视器.通常以\r转义,缩写为 CR ,并具有ASCII值130x0D.

Carriage return means to return to the beginning of the current line without advancing downward. The name comes from a printer's carriage, as monitors were rare when the name was coined. This is commonly escaped as \r, abbreviated CR, and has ASCII value 13 or 0x0D.

换行是指向下前进到下一行;但是,它已被重新调整用途并重命名.用作换行符",它终止行(通常与分隔行混淆).通常以\n转义,缩写为 LF 或NL,并且具有ASCII值100x0A. CRLF (而不是CRNL)用于\r\n对.

Linefeed means to advance downward to the next line; however, it has been repurposed and renamed. Used as "newline", it terminates lines (commonly confused with separating lines). This is commonly escaped as \n, abbreviated LF or NL, and has ASCII value 10 or 0x0A. CRLF (but not CRNL) is used for the pair \r\n.

换页是指向下前进到下一个页面".它通常用作页面分隔符,但现在也用作部分分隔符. (在源代码中通常不使用它来划分逻辑上独立的函数或函数组.)当您插入分页符"时,文本编辑器可以使用此字符.通常以\f转义,缩写为 FF ,并且具有ASCII值120x0C.

Form feed means advance downward to the next "page". It was commonly used as page separators, but now is also used as section separators. (It's uncommonly used in source code to divide logically independent functions or groups of functions.) Text editors can use this character when you "insert a page break". This is commonly escaped as \f, abbreviated FF, and has ASCII value 12 or 0x0C.

作为控制字符,可以用各种方式来解释它们.

As control characters, they may be interpreted in various ways.

最常见的区别(也许是唯一值得担心的区别)是,行在Windows上以CRLF结尾,在Unix上以NL结尾,而在较旧的Mac上以CR结尾(OS X的情况已与Unix相似).请注意,从LF到NL的含义转换,对于完全相同的字符,给出了Windows和Unix之间的差异. (Windows当然比Unix更新,因此它没有采用这种语义转换.我不知道使用CR的Mac的历史.)许多文本编辑器可以读取这三种格式中的任何一种并在它们之间进行转换. ,但并非所有实用程序都可以.

The most common difference (and probably the only one worth worrying about) is lines end with CRLF on Windows, NL on Unix-likes, and CR on older Macs (the situation has changed with OS X to be like Unix). Note the shift in meaning from LF to NL, for the exact same character, gives the differences between Windows and Unix. (Windows is, of course, newer than Unix, so it didn't adopt this semantic shift. I don't know the history of Macs using CR.) Many text editors can read files in any of these three formats and convert between them, but not all utilities can.

换页有点有趣(即使不那么直接使用),并且按照通常的页面分隔符定义,它只能出现在行之间(例如,在NL,CRLF或CR的换行符之后)或文件的开头或结尾.

Form feed is a bit more interesting (even though less commonly used directly), and with the usual definition of page separator, it can only come between lines (e.g. after the newline sequence of NL, CRLF, or CR) or at the start or end of the file.

这篇关于什么是回车,换行和换页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆