+ 4
What is the difference between the \r and \n?
Help me!
11 Réponses
+ 11
Technically, the \n is a new line control escape char, and the \r a carriage return: first move cursor to next line below, and second will move it at line start (border left)... Depending on operating systems, they use one or both of them: on unix based ones, only the \n is required to move the cursor to start of new line, while on Windows it's required to have the sequence \r\n instead ^^ (that's why on most of relatively adanced text editors, youwill have the choice at save time to record file with Windows or others new line form (also identify to 'LF' for line feed and 'CR+LF' (carriage return) ;)
+ 5
\r is useful in networking
*for info
+ 5
@Bogdan: 'useful' isn't necessarly 'important', and reciprocally ;)
+ 5
Thought of the day: Decide on what is important or what is urgent
+ 3
@Abdur - \r has nothing to do with networking.... Or at least I cannot think of any such situation.
As visph said, the end of line "character" for text files is different between Windows and Linux. In Linux the end of line is simply a "\n" (ASCII code 10), while in Windows the end of line consists of two characters: "\r\n" (ASCII code 13, followed by ASCII code 10).
+ 3
@Abdur:
Most of all escape control char are useful in networking... why \r much than other?
+ 3
@visph
mentionned it as it solved a networking bug i once had
mentionned it casually
i am being gunned down all of a sudden
+ 2
@sass
i said useful in networking
i never asserted an exclusivity
well you cannot think of it
but i assure you,
you have not programmed all in
networking
+ 2
@Abdur - I never said that I programmed everything in networking. But I really cannot think of a situation where \r would be important in networking (other than when transferring files between Windows and Linux, but in that case the issue is not networking-related :) )
Can you give us an example of such a situation? It would be a useful learning opportunity for me and everyone else reading this forum.
+ 1
@Abdur - nobody is gunning you down :)
It's just that your answer made me curious (especially since I'm a networker in my day-to-day life). So I would really like to know more about the bug you faced - if you can share the details, that is.
0
\n