Tuesday, June 23, 2009

The File Interface in Unicode Programs

Since the content of files frequently reflects the structure of data in the working memory, the file interface in a Unicode system must fulfill the following requirements:

  • It must be possible to exchange data between Unicode and non-Unicode systems.
  • It must be possible to exchange data between different Unicode systems.
  • It must be possible to exchange data between different non-Unicode systems that use different code pages.

For this reason, in Unicode programs, you must always define the code page used to encode the character-type data that is written in text files or that is read from text files.

You must also consider that a Unicode program must be executable in a non-Unicode system as well as a Unicode system. Some of the syntax rules for the file interface have therefore been modified so that programming data access in Unicode programs is less prone to errors than in non-Unicode programs.

  • Before every read or write access, a file must be opened explicitly using OPEN DATASET. Furthermore, a file that is already open cannot be opened again. In non-Unicode programs, the first time a file is accessed, it is implicitly opened using the standard settings. The statement for opening a file can be applied to an open file in non-Unicode-programs, although a file can only be opened once within a program.
  • When opening the file, the access type and type of file storage must be specified explicitly using the following additions:
  • INPUT|OUTPUT|APPENDING|UPDATE
  • [LEGACY] BINARY|TEXT MODE
When opening a file in TEXT MODE, the ENCODING addition must be used to specify the character representation. When opening a file in LEGACY MODE, the byte order (endian) and a non-Unicode code page must be specified.
In non-Unicode programs, if nothing is entered, a file is opened with implicit standard settings.
  • If a file is opened for reading, the content can only be read. In non-Unicode programs, it is also possible to gain write access to these files.
  • If a file is opened as a text file, only the content of character-type data objects can be read or written. In non-Unicode programs, byte-type and numeric data objects are also allowed.

Note

In Unicode programs, file names can also contain blank characters.



No comments:

Blog Archive