Reminder - \r\n or \n\r?

前端 未结 10 1802
轻奢々
轻奢々 2020-11-30 16:37

I just can\'t remember those. So, what is the right way to properly terminate old fashioned ASCII lines?

10条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-30 17:36

    New line depends on your OS:

    DOS & Windows: \r\n 0D0A (hex), 13,10 (decimal)
    Unix & Mac OS X: \n, 0A, 10
    Macintosh (OS 9): \r, 0D, 13
    

    More details here: https://ccrma.stanford.edu/~craig/utility/flip/

    When in doubt, use any freeware hex viewer/editor to see how a file encodes its new line.

    For me, I use following guide to help me remember: 0D0A = \r\n = CR,LF = carriage return, line feed

提交回复
热议问题