Tagging files

IBM® Open Enterprise SDK for Python supports both EBCDIC and ASCII input files.

It attempts to autodetect file encodings, but it is highly recommended that all source files be tagged with their correct encodings. You can use the chtag utility to tag input files that are not EBCDIC text, which is the default encoding for input files on z/OS®.

Binary files

To tag a file as binary, use the following command:
chtag -b <path/to/binary/file>
To verify if the file has the binary tag, use the following command:
ls -T <path/to/binary/file>
You get the following output:
b binary T=off path/to/binary/file

Enhanced ASCII support

Some applications take advantage of Enhanced ASCII support, which requires ASCII encoded text files to be tagged as ASCII text files. Python applications on z/OS also support reading files that are tagged as ASCII text files.

To tag a file as an ASCII text file, use the following command:
chtag -tc ISO8859-1 <path/to/ascii/file>
To verify that a file is tagged as an ASCII text file, use the following command:
ls -T <path/to/ascii/file>
You get the following output:
t ISO8859-1   T=on  path/to/ascii/file

Usage

If you have some source files on an ASCII platform and you want to use them on z/OS, you can tag those files with the following steps:
  1. Create a zip file of your source files on the ASCII platform.
  2. Unzip the zip file on z/OS.
  3. Tag all text files by using the following command:
    chtag -tc ISO8859-1
  4. Tag all binary files by using the following command:
    chtag -b

To copy files remotely from an ASCII platform to z/OS, you can use the sftp command, which converts every file from ASCII to EBCDIC as it copies. In this case, tagging is not necessary.

If you are redirecting to a file in a shell script, set the following environment variables; otherwise you get garbled output.
export _TAG_REDIR_ERR=txt
export _TAG_REDIR_IN=txt
export _TAG_REDIR_OUT=txt

Troubleshooting

For more information about troubleshooting incorrectly tagged files, see Errors for incorrectly tagged files.