DOS line endings

Post

Posted
Rating:
#1 (In Topic #1061)
Avatar
Regular
thatbruce is in the usergroup ‘Regular’
 Do we have a simple, straightforward way to fix files with the abominable DOS line endings? In other words, to get rid of the "\r" characters.

Amazing after all these years that I have never had to cope with this before…

I know that there are bash ways of doing it, but
"dos2unix" is not ubiquitous.
the "sed" way is witchcraft (IMPO)
cat <file> | tr -d '\r' is the most elegant but looks terrible in File.Load(Shell(cat <file> | tr -d '\r'>temp$ ( … blah blah blah

To put it simply, if I load the file all the "\r" characters remain and screw up my parsing of the file. I just want to make them "go away with extreme prejudice".

tia
b

Online now: No Back to the top

Post

Posted
Rating:
#2
Regular
vuott is in the usergroup ‘Regular’
Ehmmm… :? what if you used the native Gambas function <COLOR color="#BF0000">Replace()</COLOR> ?

   /lang/replace - Gambas Documentation

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#3
Guru
BruceSteers is in the usergroup ‘Guru’
Yep , I'm with Vuott on this

Code (gambas)

  1.  
  2. sNoCR = Replace(File.Load(sDosFileName), "\r", "")
  3.  
  4.  
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Regular
thatbruce is in the usergroup ‘Regular’
Probably because I didn't think of it.  :oops:
Thanks guys.
b

Online now: No Back to the top
1 guest and 0 members have just viewed this.