Page 1 of 1
Remove carrage return \r
Posted: Wed Jul 14, 2010 4:47 pm
by dmonti
Hello,
I have some \r characters I would like to remove.
I have tried replacing \x0D but that doesn't work. When I view the file in binary mode I can see the X'0D' chars.
Thanks
Posted: Wed Jul 14, 2010 5:32 pm
by MudGuard
Which style of Line endings do you have configured for saving the file?
(in Save-As-Dialog: File Format)?
If it is PC, then whenever you save, the \x0D are inserted automatically.
It needs to be Unix file format to not auto-add \x0D ...
Posted: Wed Jul 14, 2010 5:52 pm
by dmonti
MudGuard wrote:Which style of Line endings do you have configured for saving the file?
(in Save-As-Dialog: File Format)?
If it is PC, then whenever you save, the \x0D are inserted automatically.
It needs to be Unix file format to not auto-add \x0D ...
Saving it as Unix does get rid of them(which is helpful), but is there a way to replace them using a regular expression?
Thanks
Posted: Wed Jul 14, 2010 6:47 pm
by MudGuard
The problem is:
if you remove them and then save the file in PC format, they get re-inserted at the end of each and every line.
Posted: Thu Jul 15, 2010 8:51 pm
by dmonti
MudGuard wrote:The problem is:
if you remove them and then save the file in PC format, they get re-inserted at the end of each and every line.
Thank you for the help. Just out of curiosity, why doesn't replacing \x0D work?
Posted: Thu Jul 15, 2010 10:42 pm
by ben_josephs
It does work.
TextPad treats \x0D (carriage return) or \x0A (line feed) or \x0D\x0A as a line terminator, and doesn't include it as searchable text in the document (although if you are using regular expressions you can search for line terminator, whatever character sequence it is in the underlying file, with \n).
The Mac line terminator is \x0D.
The Unix line terminator is \x0A.
The PC line terminator is \x0D\x0A (because that's how Teletypes worked many decades before computers were attached to them).
So when you save a file in PC format TextPad terminates each line with \x0D\x0A.