readLine and line terminators

Nick Sabalausky a at a.a
Wed Jun 18 14:46:52 PDT 2008


"llee" <llee at goucher.edu> wrote in message 
news:g3bt8f$276o$1 at digitalmars.com...
> I need din.readLine to read lines that are terminated with '\n\r' with 
> these characters removed. Right now, readLine will read a line until it 
> encounters '\n' and return. It will then read the '\r' and return. I 
> wanted to know if there is a way to read a line that is terminated with 
> '\n\r' and return it with these characters removed.

Ahh, I see.

If you do this:

auto str = din.readLine();
char c;
din.read(c);

Does that put the '\n' or '\r' into the 'c' variable? (Or is that character 
just skipped? If it's just skipped, is it possible to seek back one 
character and read it?)  If so, then maybe you could use that to reconstruct 
what you need.

Or maybe you could just use either "void read(out char x)" or "size_t 
readBlock(void* buffer, size_t size)" to create your own version of 
readLine(). Although, unless I'm wrong (and I might be), creatting your own 
readLine with "read(out char)" might be slow, and creating it with readBlock 
might mke you lose out on any fancy UTF-interpreting that might be going in 
the other versions.

Or if you're using D1, Tango might have a way of doing what you want.

Sorry I can't be of more help than that.





More information about the Digitalmars-d mailing list