+ 4

What is the difference between the \r and \n?

Help me!

15th Jun 2017, 7:32 AM
Iwan
Iwan - avatar
11 odpowiedzi
+ 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) ;)
15th Jun 2017, 7:40 AM
visph
visph - avatar
+ 5
\r is useful in networking *for info
15th Jun 2017, 7:42 AM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 5
@Bogdan: 'useful' isn't necessarly 'important', and reciprocally ;)
15th Jun 2017, 8:59 AM
visph
visph - avatar
+ 5
Thought of the day: Decide on what is important or what is urgent
15th Jun 2017, 9:01 AM
Iwan
Iwan - avatar
+ 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).
15th Jun 2017, 8:36 AM
Bogdan Sass
Bogdan Sass - avatar
+ 3
@Abdur: Most of all escape control char are useful in networking... why \r much than other?
15th Jun 2017, 8:40 AM
visph
visph - avatar
+ 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
15th Jun 2017, 9:10 AM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 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
15th Jun 2017, 8:38 AM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 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.
15th Jun 2017, 8:51 AM
Bogdan Sass
Bogdan Sass - avatar
+ 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.
15th Jun 2017, 9:30 AM
Bogdan Sass
Bogdan Sass - avatar
0
\n
11th Oct 2022, 3:00 PM
Sumit Prajapati
Sumit Prajapati - avatar