Thread: Read line by line from file with EOL different that OS EOL

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    19

    Read line by line from file with EOL different that OS EOL

    Hello.
    I would like to ask if somebody know an elegant way how to read line by line from a file written in UNIX/WINDOWS/MAC format.
    The Idea is that the EOL is different when the file is written in UNIX/WINDOWS/MAC format.

    EOL – Unix format = CR
    EOL – Windows format = CRLF
    EOL – MAC format = LF

    Another question does somebody know an easy way how to find out what EOL is used in a given file?

  2. #2
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    No. The C standard library routines are only guaranteed to convert some unspecified operating system native "EOL" value of potentially multiple bytes to the compiler's native implementation of '\n'. They are not guaranteed to handle multiple encoding schemes or different "EOL" representations. In the real world, most standard library implementations only handle conversion to and from system native and compiler native.

    If you want this, you need to do this by hand. There is no magic.

    Soma

  3. #3
    Registered User
    Join Date
    Jan 2007
    Posts
    19
    Ok.
    Thanks for the information.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can you help me about tolower() in file
    By nctar in forum C Programming
    Replies: 7
    Last Post: 05-12-2010, 10:04 AM
  2. Replies: 6
    Last Post: 03-01-2010, 08:11 PM
  3. getline function to read 1 line from a text file
    By kes103 in forum C++ Programming
    Replies: 3
    Last Post: 10-21-2004, 06:21 PM
  4. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM
  5. How do I read file line by line?
    By Blurr in forum C Programming
    Replies: 1
    Last Post: 09-22-2001, 12:32 AM