POSIX string transput (The GNU Algol 68 Compiler)

### 8.7 POSIX string transput ¶

The following procedures read or write characters and strings from and to open files. The external encoding of the files is assumed to be UTF-8. Since Algol 68 `char`s are UCS-4, this means that reading or writing a character may involve reading or writing more than one byte, depending on the particular Unicode code points involved.

#### 8.7.1 Output of strings and chars ¶

Procedure: putchar `= (char c) char` ¶

  Write the given character to the standard output. This procedure yields `c` in case the character got successfully written, or `eof char` otherwise.

Procedure: puts `= (string str) void` ¶

  Write the given string to the standard output.

Procedure: fputc `= (int fd, char c) int` ¶

  Write given character `c` to the file with descriptor `fd`. This procedure yields `c` on success, or `eof char` on error.

Procedure: fputs `= (int fd, string str) int` ¶

  Write the given string `str` to the file with descriptor `fd`. This procedure yields the number of bytes written on success, or 0 on error.

#### 8.7.2 Input of strings and chars ¶

Procedure: getchar `= char` ¶

  Read a character from the standard input. This procedure yields the read character in case the character got successfully read, or `eof char` otherwise.

Procedure: gets `= (int n) ref string` ¶

  Read a string composed of `n` characters from the standard input and yield a reference to it. If `n` is bigger than zero then characters get read until either `n` characters have been read or the end of line is reached. If `n` is zero or negative then characters get read until either a new line character is read or the end of line is reached.

Procedure: fgetc `= (int fd) int` ¶

  Read a character from the file with descriptor `fd`. This procedure yields the read character in case a valid Unicode character got successfully read. If an unrecognizable or unknown character is found then this procedure yields `replacement char`. In case of end of file this procedure yields `eof char`.

Procedure: fgets `= (int fd, int n) ref string` ¶

  Read a string from the file with descriptor `fd` and yield a reference to it. If `n` is bigger than zero then characters get read until either `n` characters have been read or the end of line is reached. If `n` is zero or negative then characters get read until either a new line character is read or the end of line is reached.