Remove carrage return \r

General questions about using TextPad

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

Post Reply
dmonti
Posts: 5
Joined: Fri Jan 28, 2005 10:19 pm

Remove carrage return \r

Post 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
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post 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 ...
dmonti
Posts: 5
Joined: Fri Jan 28, 2005 10:19 pm

Post 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
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post 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.
dmonti
Posts: 5
Joined: Fri Jan 28, 2005 10:19 pm

Post 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?
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post 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.
Post Reply