Re: getline and CR, LF, CR/LF, VS/Linux



Gene Bushuyev wrote:
"Ian Semmel" <isemmel@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:O27xtnNhFHA.2916@xxxxxxxxxxxxxxxxxxxxxxx

What is the correct method for handling text files which may (or may not) have a CR character at the end of each line ?

There seems to be a difference the windows/linux VS/gcc handle the situation.


My program works OK under VS, but in linux it appears to read the first line then returns EOF ?


Windows, Mac, and Linux/Unix - all three have different EOL characters. The STL streams work correctly on all platforms as long as you read the text files in the format that corresponds to that platform. If you're writing in one platform format and try reading in another, you are on your own. Either process EOL yourself, or convert text files, for example, using dos2unix (unix2dos) utils.

Gene



Thanks. Another example of the NSTL (Nearly Standard Template Library).

I changed my program to call stream.get( c ) and strip out all CR characters. There might be a better way but that works.
.




Relevant Pages

  • Re: Could someone run this program on a pc which does not have a standard english configuration
    ... is set vary widely from platform to platform. ... the native-language characters, ... I tried running the code on 3 Linux distributions (SuSE, Redhat, ... It may be that the 'native codeset' was the same. ...
    (comp.std.c)
  • Re: SED Usage
    ... Because it is coming from another platform, ... > Character and then subsequent unprintable characters after ... > thru hex FE), is in fact catching more than desired. ... * To join/leave the list, search archives, change list settings, * ...
    (comp.sys.hp.mpe)
  • Re: filesize of an ofstream
    ... >in a platform specific support group for that. ... there is no guarantee that the value provided by that ... >function will equal the number of characters that you can read from ... access violations trying to use those functions (they're protected, ...
    (comp.lang.cpp)
  • Re: n00bie - Use of ANSI and/or UniCode Characters ......
    ... all characters are by definition Unicode characters. ... Note U+20A0 is not the official euro symbol. ... it does properly convert to the platform default characters. ... default encoding is Cp1252 which is the Windoze encoding. ...
    (comp.lang.java.help)
  • Re: Could someone run this program on a pc which does not have a standard english configuration
    ... latin or anything similar to English. ... environments, the characters displayed when the 0x80 bit ... is set vary widely from platform to platform. ... the native-language characters, ...
    (comp.std.c)

Loading