EOL (end of line) characters are invisible characters that mark the end of a line in text files. They define the line breaks. Windows uses a combination of CR and LF characters (carriage return and line feed) whereas Mac and Linux uses only LF. As M2TW is a Windows game it requires the CR+LF format.
Sometimes when editing a text file the editor uses the wrong EOL characters: LF instead of CR+LF. As a result the file looks perfectly fine but the game doesn't work correctly, for no apparent reason.
Notepad++ is an excellent editor and includes some handy tools to find and fix these problems. It can also be the cause of the problems but so can any other editor.
Clicking the "Show All Characters" button on the toolbar displays the EOL characters...
In that image we can see that lines end with LF. It should look like this instead...
The status bar at the bottom shows the EOL format being used. "Dos\Windows" indicates that the correct format is in use: CR+LF. (But not always! See below.)
Fixing is simple. If the status bar does not say "Dos\Windows" then use Edit > EOL Conversion > Windows format from the menu...
After fixing the file, save it.
Not Always...
I have found that sometimes Notepad++ says "Dos\Windows" but some lines still have LF instead of CR+LF. There is a way to hunt them down...
Using Notepad++'s "Find" function, search the file for [^\r]\n using the Regular expression option...
It will find all occurrences of lines that end with LF only.
(NOTE: earlier versions of Notepad++ wouldn't find them. I don't know in what version it started working but v6.6.7 works.)
Even better is to use the "Find in Files" function...
...because that will search every file at once when you hit the Find All button.
- Directory: use the mod folder and be sure to tick the In all sub-folders option.
- Filters: not required but *.txt *.xml *.modeldb will limit the search to text files only, avoiding image files etc. which will only slow it down.
Encoding
While we're talking Notepad++, notice the encoding display in the status bar. For files in the "text" folder this should be "UCS-2 Little Endian" and for all other files it should be "ANSI". The Encoding menu can be used to change it if it is not correct. (I have read that the "Convert to..." options should be used instead of the "Encode in..." ones.)
This has nothing to do with EOL characters but incorrect encoding can be another source of mysterious game issues.
Note that ANSI files should not contain "extended ASCII" characters such as ë, only 'plain' characters. For example, "Finwë" should not be used in script, export_descr_ancillaries.txt, etc. (even in comments) because ë is not an ANSI character. How the game deals with that I do not know but editors might convert that character into something else so it is best to avoid having them in there to begin with. (They are fine in "text" folder files because they are legal characters in UCS-2 Little Endian encoding.)
To find non-ANSI character occurrences in your files you can search for them in Notepad++ using [^\x00-\x7F] with the Regular expression option.
Lastly, if you're not already aware of the brilliant Syntax Highlighter for TW files in Notepad++ then check this out:
http://www.twcenter.net/forums/downl...o=file&id=1867 (download)
http://www.twcenter.net/forums/showt...tom-Word-Files (info thread)