MacOS的行尾以回车字符结束,许多文本处理工具将这样的文件作为一行来处理。
Mac OS ends lines with the carriage return character, and many text processing tools treat such files as a single line. To fix that, we can use the following tricks.
也可处理以空格、分号、制表符、回车或任何其他可识别字符分隔的列表。
A list separated by Spaces, semicolons, tabs, carriage returns, or any other identifiable character can be processed.
还可以注意到,write系统调用的结果是写入字符的个数数目,在这个示例中为17加上一个回车。
Also note that the result of the write system call is the number of characters written — in this case, 17 plus one carriage return.
得到的结果是一个类似于“ [CR] ”的字符串,其中 [CR] 表示回车符。
The result is a string something like " [CR] " where [CR] is a carriage return.
例如,如果您想要导出一些Wiki页面,您会希望保留一些字符的原始位置,如回车符和换行符,因为这些字符在wiki格式中有特殊的作用。
For example, if you export Wiki pages, you will want to retain the exact positions of characters like return and line-feed because those are given special attention in the Wiki format.
如果他只是按下了回车,read_line函数将返回一个空字符串,这样的输入会被认为是一种用户希望继续进行检索的暗示。
If he just presses Enter, the read_line function will return an empty string, and such input is taken as an indication that the user wants to go on.
由其名称可以明显看出,display是打印出参数的函数,而newline是只打印出一个回车换行字符的函数。
As is obvious from their names, display is a function that prints out its argument and newline is a function that simply prints out an end-of-line character.
作为一名作者,您可能习惯使用文字处理软件的格式和回车键(输入字符,选择一种格式,按回车,再次输入字符,选择另外一种格式,按回车,依此类推)。
As an author, you might be used to working with your word processor's formatting plus the Enter key. (you type, choose a format, press Enter, type more, choose another format, press Enter, and so on.)
对文本模式的文件,回车换行作为一个字符。
For text-mode files, carriage return–linefeed pairs are counted as single characters.
对文本模式的文件,回车换行作为一个字符。
For text-mode files, carriage return–linefeed pairs are counted as single characters.
应用推荐