Carriage Return showing in notepad++ but not textpad?

随声附和 提交于 2020-01-13 08:58:30

问题


I have some text files copied out to a server. I typically use and prefer notepad++ to look at text files but on this server, only textpad is installed. This is really strange behavior but I noticed that when I view the EOL chars in notepad++ I can clearly see and search for the CRLF (i.e. \r\n). But when I display the same files in textpad, I am able to search only on the LF (\n) and do not have any hits on the CR (\r). Am I missing something on how Textpad is interpreting the EOL chars?


回答1:


This happens when the EOL control characters are not correct. Windows represents newlines with the carriage return + line feed.

In Notepad++, you can check for these characters by selecting:

View > Show Symbols > [x] Show End of Line

You need to modify your script so your data is formatted like this:

CRLF




回答2:


Yes ideally it's carriage return and followed by line feed,

\r\n

but you can also use a quick shorthand to place {lf} rather then {cr}{lf}

\n




回答3:


I know this is a slightly old question, but I struggled with this exact problem, and here is how I found a workaround.

When using Save As in textpad you can specify the file format at the bottom (PC, UNIX, or Mac). If you choose UNIX in theory this ends lines only with the \n character, however you have to change this option every time.

You can change the preferences for specific "Document Classes" to specify the output file format. Follow these steps:

  • Click Configure
  • Go to Preferences
  • Expand the Document Classes list
  • Select bash, which should include *.sh files
  • Scroll down the options on the right until you see Create new files as
  • Select UNIX

This should now save all *.sh files you create as UNIX format without the carriage returns. Good luck

I found this info here: http://homes.ori.org/~keiths/Files/Tips/Software_TextPad_Prefs.html#DocClasses



来源:https://stackoverflow.com/questions/17088242/carriage-return-showing-in-notepad-but-not-textpad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!