Text streams contain printable characters and control characters that are organized into lines. Each line consists of zero or more characters and ends with a new-line character (\n). A new-line character is not automatically appended to the end of file.
The ILE C/C++ run-time environment may add, alter, or ignore some special characters during input or output so as to conform to the conventions for representing text in the iSeries environment. Thus, there may not be a one-to-one correspondence between characters written to a file and characters read back from the same file.
Data read from an integrated file system text stream is equal to the data which was written if the data consists only of printable characters and the horizontal tab, new-line, vertical tab, and form-feed control characters.
For most integrated file system stream files, a line consists of zero or more characters, and ends with the following character combination: a carriage return plus a new-line character. However, the integrated file system can have logical links to files on different systems that may use a single line-feed as a line terminator. A good example of this are the files on most UNIX systems.
On input, the default in text mode is to strip all carriage-returns from new-line carriage-return character combination line delimiters. On output, each line-feed character is translated to a carriage-return character that is followed by a line-feed character. The line terminator character sequence can be changed with the CRLN option on fopen().
When a file is opened in text mode, there may be code-page conversions on data that is processed to and from that file. When the data is read from the file, it is converted from the code page of the file to the code page of the application, job, or system receiving the data.
When data is written to an iSeries file, it is converted from the code page of the application, job, or system to the code page of the file. For true stream files, any line-formatting characters (such as carriage return, tab, and end-of-file) are converted from one code page to another.
When reading from QSYS.LIB files end-of-line characters (carriage return and line feed) are appended to the end of the data that is returned in the buffer.
The code-page conversion that is done when a text file is processed can be changed by specifying the code-page or CCSID option on fopen(). The default is to convert all data read from a file to the job's CCSID or code page.
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.