readLine and line terminators
llee
llee at goucher.edu
Wed Jun 18 14:04:15 PDT 2008
Nick Sabalausky Wrote:
> "llee" <llee at goucher.edu> wrote in message
> news:g3br0o$21np$1 at digitalmars.com...
> > I'm parsing a cgi request and was using the din.readLine function to get
> > each line. readLine will read bytes from a stream until it encounters
> > either '\n' or '\r'. I need it return lines terminated with "\n\r". Does
> > anyone know how to do this. Or if there are any other options.
>
> I'm not familiar with the details of the text IO APIs, but you could always
> just wrap it in another function like this:
>
> //Psuedocode
> string ReadLineGuaranteeLineEnding() // Could probably think of a better
> name
> {
> // Read from din.readLine
> // Check for and remove any trailing '\n' and '\r'
> // Append "\n\r"
> // Return result
> }
>
>
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.
More information about the Digitalmars-d
mailing list