最近在用ubuntu,不时需要在windows和ubuntu之间切换,偶尔发现同样的文档打开效果不一样猜测是换行符的问题。wikipidia 讲述的巨详细,才发现小小的换行符有这么多门道。
The ASCII standard for text does not define a unique end-of-line (EOL) character. Instead, ASCII defines two independent and orthogonal movements of the print head: Carriage Return (CR) and Line Feed (LF). (IBM's EBCDIC did not make this mistake; it defined a single New Line (NL) character.)
Early operating system designers had to adopt some "end-of-line" convention using CR and LF; some used LF, some used CR, and some used a two-octet sequence: LF CR or CR LF. During the early ARPAnet research days (~1970-1972), this end-of-line diversity among operating systems made network communication between diverse host systems difficult.
After some discussion (recorded in early RFCs), the researchers adopted a single convention: ASCII text transmitted across the network *must* use the two-character sequence: CR LF. This choice was designed to spread the pain equally among all operating systems of the day; each has to translate to and from the CR LF convention when text was transferred across the network. This EOL convention was the core of the initial Telnet protocol definition (negotiated options were added later). Jon Postel was one of the principal protocol policemen enforcing the CR LF requirement. He carried the EOL = CR LF convention Telnet into FTP and SMTP on the ARPAnet, and later these protocols were taken essentially unchanged into the Internet.
Few people today are aware of the EOL issue, because systems generally (but not always!) make it transparent. For example, the RFC Editor stores the official RFC archive on a Unix system whose native EOL is a single LF. When you click on a link for an RFC from the RFC Editor Web page, your browser uses an FTP client to retrieve the ASCII text. The RFC's FTP server translates the LF in each text line into CR LF for transmission across the Internet, and your FTP client in turn translates each CR LF into whatever the EOL convention of your system. Many today use Windows, based on MS-DOS, which came along later and adopted CR LF as its EOL convention. This simplifies the picture; no EOL translation is actually required when MS-DOS systems move text across the Internet.
RFC 2223, "Instructions for RFC Authors", describes the format of an RFC; it says that every line of an RFC is to be ended by CR LF. This means, *as transmitted across the Internet*; the text is actually stored at ISI and other Unix sites with LF as the EOL delimiter. It should all work, magically. However, misconfiguration or mismatches can still cause confusion about EOL. For example, you may see an extra ^M (Control M, or CR) at the end of every line of an RFC. Or you may be missing the CR entirely, causing bad formatting on a Windows system. On a Unix system, you may have to run the unix2dos utility to remove spurious ^M characters.
Note that if you use binary mode FTP, the file is transferred literally byte-by-byte, so the source host's end of line is sent across the network. This normally works OK because it is assumed that binary mode FTP is used only between like systems. The RFC Editor Web page includes tar'd and zip'd collections of RFCs (www.rfc-editor.org/download.html). These compressed files are binary and therefore contain buried EOL sequences. The tar.Z files use the Unix convention (LF), while the .zip files are assumed to be destined for Windows machines and therefore use the MS-DOS convention.
详细解决方案
The End-of-Line Story
热度:8 发布时间:2024-01-06 03:31:28.0
相关解决方案
- Expression dqgrade is undefined on line 20, column 30-freemarker报这样的错如何解决
- MySQL 5.5 Command Line Client 窗口1输密码就退出
- 谁帮小弟我看下Source not found for ResponseFacade.sendRedirect(String) line: 483
- 运行程序时报java.lang.IllegalArgumentException: No line matching interface Clip supporting format PCM_SIGNED, 11025.0 Hz, 16 bit, mono解决方案
- read.line()函数有关问题
- chart line 图点的大小怎么设置
- 紧急求救!点分页,点多几次出现"stack overflow at line:0"该怎么解决
- 怎么实现SHAPE.LINE.IMAGE等控件,用鼠标自由拉审长短
- 求相助org.hibernate.hql.ast.QuerySyntaxException: unexpected token: id near line 1
- stack overflow at line 0求解!解决方案
- stack overflow at line 零求解
- Narcissus and Echo's story.该如何处理
- Narcissus and Echo's story.该如何解决
- -Bad line 52 in /etc/environment ' not a valid identifier-解决方案
- -Bad line 52 in /etc/environment ' not a valid identifier-解决方法
- -Bad line 52 in /etc/environment ': not a valid identifier-该怎么处理
- 1254-055 Dependency line needs colon or double colon operator解决方案
面向对象开发方法又称为快速原型化, 客观世界是由各种各样的对象组成的,每种对象都有各自的内部状态和运动规律,不同对象之间的相互作用和联系就构成了各种不同的系统。经历以下过程:
虽然 我们在网站目录下有一份copy,但是假如我们修改了代码库如何让网站目录下的代码也同步更新呢,下面我们使用钩子可以实现
(1)k{n},表示n个k- Print a single line containing the largest sum using the traversal spe ...
- 小弟我在Windows下安装Memcached成功之后,测试出现Failed reading line from stream异常
- u盘装系统之/scripts/casper-premount/2-iso_scan: line 46 can't open /dev/sr0: No Medium found解决办法
- ADODB.Connection '800a0e78' 对象关闭时,不允许操作。 \result.asp, line 29解决办法
- $line[一] = intval($line[1]); //这个这样写是什么意思
- Parse error: syntax error, unexpected T_STRING in C:\AppServ\www\1.php on line 三
- IE6、IE7、IE8、FireFox css line-height兼容有关问题