Announcement

Collapse
No announcement yet.

Convert Unix text to Dos Text

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Convert Unix text to Dos Text

    Any guidance?
    I have a text file that I read sequentially. If the text
    file is DOS it reads line by line but in UNIX it reads the
    whole file. Anybody have any ideas about determining if it is
    a unix text file then converting it to a DOS file? I am thinking
    that this is a CR/LF problem.

    Thanks,

    Brad


    ------------------
    Thanks,

    Bradley Callis

    #2
    hi bradley

    unix end-of-line is lf only not crlf. the reason that you're
    not reading each line correctly on unix type text is that
    you're probably using line input which expects crlf.

    to check if it's a unix type file look for the first lf and
    then determine if there is a cr before the lf. if yes you're
    on dos/windows otherwise unix type.

    you might want to check out patrice terrier's bufin replacement
    for line input at http://www.powerbasic.com/support/pb...ad.php?t=22634
    which enables you to choose the end of line delimiter you want (use
    the setbufinchar$($lf) function to set the end-of-line marker).
    that way you could use lf as the end-of-line marker which would
    work for both dos and unix style text.

    cheers

    florent



    [this message has been edited by florent heyworth (edited august 21, 2000).]

    Comment


      #3
      Florent,

      Thanks for the quick reply. Still battling with the API calling structure
      and slowly reading through Petzold. His example thoroughly confuses me,
      to say the least. I am enjoying the learning curve, and will understand
      it eventually. Would it be possible, without API calls to replace the LF
      with a CRLF first? I will try the replace function next. Thanks again.



      ------------------
      Thanks,

      Bradley Callis
      Thanks,

      Bradley Callis

      Comment

      Working...
      X
      😀
      🥰
      🤢
      😎
      😡
      👍
      👎