Reading Files (was: Reading Files and ASCII Code)

Reading Files (was: Reading Files and ASCII Code)

Post by Ulrich Eck » Fri, 08 Sep 2006 16:31:55

Then make two postings, for the sake of clearness. ;)

There is no such thing. Everyday HTML comes encoded as ISO8859-1, everyday
XML comes encoded as UTF-8, everyday C++ sourcecode come (on many
platforms) encoded as ASCII. Other files might use other encodings.

Assuming you are using C++ IOStreams, the position for a read is always
implicitly the current position. You could use read() or readsome() or even
one of the get() overloads. Be aware that istreams by default skip
whitespace, so you need to explicitly tell it not to do so. Also, by
default, files are handled as textfiles, i.e. CR/LF conversion is done -
use the ios_base::binary flag to avoid that. You might want to skip
iostreams alltogether and go to the lower-level streambuffers instead -
these are used by the streams to do (almost) just the character IO and no
formatting or interpretation.

No problem, there are functions for seeking in a file.

Yes, see or any better C++ book (in case you don't
have one, check out the book reviews at