提醒 - \ r \ n或\ n \ r?

本文翻譯自:Reminder - \r\n or \n\r?

I just can't remember those. 我只是記不住那些。 So, what is the right way to properly terminate old fashioned ASCII lines? 那麼,正確終止舊式ASCII行的正確方法是什麼?


#1樓

參考:https://stackoom.com/question/RRIf/提醒-r-n或-n-r


#2樓

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/ 更多細節: 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 = ca rr iage r eturn, li n e feed 對我來說,我使用以下指南來幫助我記住:0D0A = \\ r \\ n = CR,LF = ca rr iage r eturn,li n e feed


#3樓

\\r\\n

Odd to say I remember it because it is the opposite of the typewriter I used. 奇怪的是我記得它,因爲它與我使用的打字機相反
Well if it was normal I had no need to remember it... :-) 好吧如果這是正常的我沒有必要記住它... :-)

來自維基百科的打字機 * Image from Wikipedia *來自維基百科的圖片

In the typewriter when you finish to digit the line you use the carriage return lever , that before makes roll the drum, the newline , and after allow you to manually operate the carriage return . 在打字機中,當你完成數字線的使用時,你使用了回車杆 ,在滾筒之前滾動, 換行 ,然後允許你手動操作回車

You can listen from this record from freesound.org the sound of the paper feeding in the beginning, and at around -1:03 seconds from the end, after the bell warning for the end of the line sound of the drum that rolls and after the one of the carriage return. 您可以從freesound.org這條記錄中聽到開始時紙張進給的聲音,以及距離結束大約-1:03秒的聲音,在響鈴滾動的聲音結束後的鈴聲警告之後回車之一。


#4樓

\\r\\n for Windows也可以。


#5樓

我會用“ r etur n ”這個詞來記住,r來自n之前。


#6樓

The sequence is CR (Carriage Return) - LF (Line Feed). 順序是CR(回車) - LF(換行)。 Remember dot matrix printers? 還記得點陣打印機嗎? Exactly. 究竟。 So - the correct order is \\r \\n 所以 - 正確的順序是\\ r \\ n

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章