Monday, November 8, 2010

How does eclipse figure if a file has unix or dos-style line endings?

Hey,

I am looking at some Java Code in Eclipse on Windows. The line termination characters (DOS-style) do not display properly (empty lines everywhere..).

The Problem is that the Code is from a Windows ClearCase vob for which I do not have check-in permissions, so it is read-only (changing the line-termination characters with auto-format is not possible). Creating a full copy and changing the line termintators is out of the question as the code might change while I am looking at it..

I found Preferences->Workspace->"New text file line delimiter", but it seems that this does not display the line termination characters in existing files properly.

How do I make eclipse display the text file as it was meant to display?

Edit: Notepad displays the file correctly. Ultra-Edit also detects it as unix-style and suggests converting it to DOS (but displays properly when declining it). gvim detects the file as unix and displays ^M and the end of the line.

I have checked the file in binary and it does not contain any \n characters that do not follow a \r character. Could there be any other way that Eclipse distinguishes unix from dos-style line endings?

I found this sequence of characters: 0d0d 0a0d 0d0a (\r\r\n\r\r\n). I suppose this is why it does not work..


View the original article here

No comments:

Post a Comment