Skip to content

Instantly share code, notes, and snippets.

@harrifeng
Created October 4, 2017 10:10
Show Gist options
  • Save harrifeng/d317aba7e32907fff9d0180737c7e5c6 to your computer and use it in GitHub Desktop.
Save harrifeng/d317aba7e32907fff9d0180737c7e5c6 to your computer and use it in GitHub Desktop.
CR, LF, CR/LF区别与关系
前言
在文本处理中,CR(Carriage Return),LF(Line Feed),CR/LF是不同操作系统上使用的换行符,具体如下:
Dos和Windows采用回车+换行CR/LF表示下一行
而UNIX/Linux采用换行符LF表示下一行
苹果机(MAC OS系统)则采用回车符CR表示下一行
区别
CR与LF区别如下:
CR用符号\r表示,十进制ASCII代码是13,十六进制代码为0x0D
LF使用\n符号表示,ASCII代码是10,十六制为0x0A
所以Windows平台上换行在文本文件中是使用0d 0a两个字节表示,而UNIX和苹果平台上换行则是使用0a或0d一个字节表示。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment