Difference between revisions of "Return symbol"

From LemonWiki共筆
Jump to: navigation, search
m (如何看到換行符號)
(如何取代換行符號)
 
Line 104: Line 104:
 
* MySQL: {{kbd | key=<nowiki>SELECT REPLACE(REPLACE(REPLACE(`column`,'\r\n',''),'\n',''),'\r','') </nowiki>}} <ref>[https://stackoverflow.com/questions/13273343/replace-new-line-character-in-mysql-not-working sql - REPLACE new line character in MYSql not working - Stack Overflow] </ref>
 
* MySQL: {{kbd | key=<nowiki>SELECT REPLACE(REPLACE(REPLACE(`column`,'\r\n',''),'\n',''),'\r','') </nowiki>}} <ref>[https://stackoverflow.com/questions/13273343/replace-new-line-character-in-mysql-not-working sql - REPLACE new line character in MYSql not working - Stack Overflow] </ref>
 
* Excel: [https://www.ablebits.com/office-addins-blog/2013/12/03/remove-carriage-returns-excel/ 3 ways to remove carriage returns in Excel: formulas, VBA macro, find&replace dialog] {{access | date = 2018-05-24}}
 
* Excel: [https://www.ablebits.com/office-addins-blog/2013/12/03/remove-carriage-returns-excel/ 3 ways to remove carriage returns in Excel: formulas, VBA macro, find&replace dialog] {{access | date = 2018-05-24}}
 +
* Python way: [https://stackoverflow.com/questions/275018/how-can-i-remove-a-trailing-newline-in-python How can I remove a trailing newline in Python? - Stack Overflow] {{access | date = 2019-06-14}}
  
 
== Related articles ==
 
== Related articles ==

Latest revision as of 12:00, 14 June 2019

換行符號 (Return symbol, line terminators, line endings, newline, end of line (EOL), line feed or line break)

  • On Win Os windows.png : CRLF = \r\n
  • On Unix, Linux Os linux.png & recent versions of Mac Os mac.png : LF = \n
  • On classic versions of Mac Os mac.png [1][2] e.g. Mac OS 9: CR = \r

如何使用編輯軟體,看到換行符號[edit]

查看每一行使用的換行符號

  • Notepad++ On Win Os windows.png 選單 → 檢視 → 特殊字元 → 顯示行尾字元 (EOL)
  • RawLineEdit for Sublime text
    • 換行符號是 CRLF = \r\n 每行最後顯示的是 <0x0d>¬
    • 換行符號是 LF = \n 每行最後顯示的是 ¬ 象形符號 (glyph)
    • 換行符號是 CR = \r 每行最後顯示的是 <0x0d>
  • BASH cat command e.g. cat -e <filename>
    • 換行符號是 CRLF = \r\n 每行最後顯示的是 ^M$
    • 換行符號是 LF = \n 每行最後顯示的是 $
    • 換行符號是 CR = \r 每行最後顯示的是 ^M

查看檔案使用的換行符號

檔案內容 File command 偵測結果
換行符號是 CRLF = \r\n UTF-8 Unicode text, with CRLF line terminators
換行符號是 LF = \n UTF-8 Unicode text Icon exclaim.gif
換行符號是 CR = \r UTF-8 Unicode text, with CR line terminators
特例: 換行符號夾雜 \r\n\r UTF-8 Unicode text, with CRLF, CR line terminators
特例: 換行符號夾雜 \r\n\n UTF-8 Unicode text, with CRLF, LF line terminators
特例: 換行符號夾雜 \n\r UTF-8 Unicode text, with CR, LF line terminators
特例: 無內容的空檔案 empty

不同換行符號 在不同作業系統的編輯器看到的文件狀況[edit]

檔案內容 Windows 10 內建「記事本」 Windows 10 免費編輯器 Notepad++ v. 7.5.9 Mac 內建「文字編輯.app Mac 編輯器 Sublime Text v. 3.2
換行符號是 CRLF = \r\n ok ok ok ok
換行符號是 LF = \n Icon exclaim.gif 預期不同行的內容擠在一起 ok ok ok
換行符號是 CR = \r Icon exclaim.gif 預期不同行的內容擠在一起 ok ok ok

如何取代換行符號[edit]

Related articles[edit]

References