[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ] Reading data

Function: read &optional iport

Function: read-char &optional iport

Function: peek-char &optional iport

Function: read-byte &optional iport
Reads one byte from an input port iport, and returns an integer in the range between 0 and 255. If iport has already reached EOF, an eof object is returned.

Function: read-line &optional iport
Reads one line (a sequence of characters terminated by newline or EOF) and returns a string. The terminating newline is not included. This function recognizes popular line terminators (LF only, CRLF, and CR only). If iport has already reached EOF, an eof object is returned.

Function: read-block nbytes &optional iport
Reads nbytes bytes from iport, and returns an incomplete string consisted by those bytes. The size of returned string may shorter than nbytes when iport doesn't have enough bytes to fill. If iport has already reached EOF, an eof object is returned.

If iport is a file port, the behavior of read-block differs by the buffering mode of the port (See section 6.18.3 File ports, for the detail explanation of buffering modes).

Read-block returns newly allocated string every time. If you want to avoid allocation and read the data into a pre-allocated fixed-length buffer, you can use read-block! in gauche.uvector module (See section 9.24.4 Uvector block I/O). It uses a uniform vector as the buffer.

If you want to write a chunk of bytes to a port, you can use either display if the data is in string, or write-block in gauche.uvector (See section 9.24.4 Uvector block I/O) if the data is in uniform vector.

Function: eof-object? obj
[R5RS] Returns true if obj is an EOF object.

Function: char-ready? port
[R5RS] If a character is ready to be read from port, returns #t.

For now, this procedure actually checks only if next byte is immediately available from port. If the next byte is a part of a multibyte character, the attempt to read the whole character may block, even if char-ready? returns #t on the port. (It is unlikely to happen in usual situation, but theoretically it can. If you concern, use read-block to read the input as a byte sequence, then use input string port to read characters.)

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Ken Dickey on November, 28 2002 using texi2html