Link to home
Start Free TrialLog in
Avatar of loudinbk
loudinbk

asked on

Convert EOL character (UNIX to PC)

What is the easiest way to convert every EOL character in a ascii file.  I need to convert from a Line Feed (Unix Style) to a Carriage Return + Line Feed (PC Style).
ASKER CERTIFIED SOLUTION
Avatar of EDDYKT
EDDYKT
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
A non-VB solution is to load the file into Wordpad then save.  It will tell you that you're about to lose the formatting, which will convert the LFs into CRLFs.

Obviously this is not ideal if you'll be doing this on many files or on a regular basis.

Also, the way I prefer in EDDYKT's code is to replace the Get with Input:

...
   Open fileName For Binary As #ff
   s = input$(lof(ff), #ff)
   Close ff
...

Same result.

Also, the line:

       Print #ff, s

should be

   Print #ff, s

to prevent a new CRLF from appearing at the end of the document.
That print should end in a semicolon:

Print #ff, s;