IBM Support

How to automate conversion of text files from EBCDIC to ASCII

How To


Summary

Some IBM i programs generate stream files (STMF) in the IFS encoded in EBCDIC (CCSID 37).
These files are not viewable on non-IBM i platforms without first converting them to another code page such as ASCII.

Objective

This document shows to to set up automatic conversion of EBCDIC stream files in the IFS to ASCII when downloaded via IBM i NetServer.

Steps

1) Ensure the IBM i  GO NETS tool is installed via the commands :

  ADDLIBLE NETSRVCMD    GO NETS

If either of these fail, first install GO NETS using How to manage IBM i NetServer without Navigator

2) Create a new NetServer share with text conversion enabled. For example:

  ADDNSVFSHR SHARE(HOMECNV) DIR('/home') TEXT('This share will convert ".cnv" files from EBCDIC') ACCLVL(*RW) DTACVN(*COMPLEX) FILEEXT(CNV)

Any of these values can be changed as desired, however, the underlying DIR specified must exist (/home, in this case).

GO NETS <enter> and then option 11. Work with Shares, and option 5=Display on the "HOMECNV" share will show the following:

Image of NetServer share properties

3) Map a network drive to the "HOMECNV" share and open a file with extension ".cnv" that is encoded in EBCDIC. It should display in ASCII.

If you want all EBCDIC stream files to be converted, regardless of the file extension, simply specify * for the FILEEXT parameter.

Additional Information

One example of a text/STMF file that is created on the IBM i in EBCDIC is QSH trace output. Assuming you have a valid $HOME directory, the above functionality can be tested with command:

QSH CMD('set -t; pwd; set +t')

You will then have a file "qsh_trace" in your home directory (Usually /home/<your_USRPRF> ) which is encoded in EBCDIC. Unconverted, it will not be readable on a PC.

Rename it with:

RNM OBJ('~/qsh_trace') NEWOBJ(qsh_trace.cnv)

...and then open qsh_trace.cnv using the NetServer share configured to convert text files with ".cnv" extension.

[{"Business Unit":{"code":"BU070","label":"IBM Infrastructure"},"Product":{"code":"SWG60","label":"IBM i"},"Component":"NetServer","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"LOB68","label":"Power HW"}}]

Document Information

Modified date:
17 January 2025

UID

ibm10719729