^M characters

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
Larry Greene

^M characters

Post by Larry Greene »

Well ... some of the simplest errors can cause great frustration.

I have been pulling out what little hair I have left over a couple of PHP files I created using TextPad ... and finally, after sticking them on a disc and throwing them in my Linux machine using that every handy dandy editor ... vi ... I can see the one file that my webserver is constantly belching out a 500 Internal Server Error is riddled with Windows carriage returns (^M). I thought TextPad was a pure text editor ... no windows characters! I have looked thru the preferences to make sure there is no "Turn off Windows Carriage Return" settings but have not found anything. Does anyone out there know why TP would do that to one of the files???

Thanks
LarryG
Ed Orchard

Re: ^M characters

Post by Ed Orchard »

I think that the problem with this file is that it has been saved in UNIX format.
Ensure that Preferences/Document Classes/Default/Create New Files As is set to PC. I'm sure there is a way to convert a Unix file to PC format but can't remember at the moment.
Ed Orchard

Re: ^M characters

Post by Ed Orchard »

Sorry, please ignore my original response. The ^M is a CR character not a windows character and it indicates that the file has been saved in PC format. TextPad will, by default, save in PC format. To save as a UNIX file (the only difference is the line termination sequence) then “save As” and select UNIX
Jan Paul

Re: ^M characters

Post by Jan Paul »

There is an utility in the Utility section of the download pages of Textpad. These utilites are TODOS.exe and TOUNIX.exe.
You can do the trick of transferring file from and to unix very easaly with this utilities.
Robbage

Re: ^M characters

Post by Robbage »

^M is hardly Windows-specific though :) Most of the internet relies on CR+LF to work.
Andreas

Re: ^M characters

Post by Andreas »

If you transfer these files via ftp, make sure ASCII mode is selected, then the conversion of line ends will be done automatically.

Otherwise, either save from Textpad as suggested in Unix format, or in vi replace the ^M by nothing.
:s/^M//g
is the vi command to do so.
To get it, type :s/ then hit Ctrl+V Ctrl+M then type the rest.
Post Reply