How To
Summary
How to copy an EBCDIC stream file from a directory on IBM i to an ASCII/ANSI stream file on a client.
Objective
If the data in a stream file copied from IBM i contains data that looks like the following, then you copied a file with EBCDIC data and it wasn't converted to your client code page.
ùóøô÷ò@@kÈ…••‰•‡@kÇ@Òkôøõù@Å“”@Á¥…@kÄ““¢kãçk÷õòñ÷@@kõððð@@kó@@kó÷Kðð@@@kKðð@@@@@
%øóùòøó@@kÑ–•…¢@@@kÂ@ÄkòñÂ@Õæ@ñóõ@â£kÓ¨@@kÕèkñóðôñ@@kôðð@@@kñ@@kñððKðð@@kKðð@@@@@
%øóùòøó@@kÑ–•…¢@@@kÂ@ÄkòñÂ@Õæ@ñóõ@â£kÓ¨@@kÕèkñóðôñ@@kôðð@@@kñ@@kñððKðð@@kKðð@@@@@
This document explains how to confirm whether a file has an EBCDIC CCSID and how to convert it to ASCII or ANSI. Converting it makes it readable in an environment that doesn't use EBCDIC.
Environment
On IBM i, there are a few ways to determine the CCSID (Coded Character Set IDentifier) of a stream file. The CL command DSPATR can be used to display the attributes of a stream file. Using option 8 from the WRKLNK screens does the same thing. For example, DSPATR '/mikswens/ebcdic.txt' shows me that the CCSID for that file is 37, which is US English EBCDIC. Click here for a list of CCSIDs defined on IBM i. In a shell environment like Qshell or PASE the attr command can be used to retrieve the CCSID attribute: attr ebcdic.txt CCSID
Presently, IBM Navigator for i does not have the ability to convert the CCSID of stream files when it copies them to a client computer. This tool performs a binary download only so there is no consideration for the CCSID of the file.
As of version 1.1.8.5 the IBM i Access Client Solutions IFS plug-in has an option on the Download action to save the file in UTF-8.
Steps
There are several ways to deal with this issue. The file can be converted to a more usable CCSID on IBM i or the copy process can convert it.
To convert the file from EBCDIC to ANSI, use the CPY command. Because the CPY command puts the copy in your current directory, first set that directory to make the new file easy to find, then use CPY to create a new file in ANSI:
CD '/mikswens'
CPY OBJ(ebcdic.txt) TOOBJ(ansi.txt) TOCCSID(1252) DTAFMT(*TEXT)
That creates a new file, /mikswens/ansi.txt, with a CCSID of 1252 (Windows, Latin 1, which is what my US English version of Windows assumes all files are coded in).
If you make use of Windows or Samba to map drives to IBM i NetServer shares, then you can take advantage of a feature of the NetServer to convert CCSIDs. This technote explains how to set a share so that it performs conversion: How to automate conversion of text files from EBCDIC to ASCII. Note, I normally add * as the extension and then all files that are in EBCDIC are converted by using the share.
The FTP utility has a feature to convert files as well by setting the representation mode to ASCII. Here is an example of how to access the IFS by using name format 1 and copying a file named ebcdic.txt to a file on my PC named ascii.txt
C:\Users\Public\Documents\IBM>ftp rch730a
Connected to rch730a.rchland.ibm.com.
220-QTCP at RCH730A.RCHLAND.IBM.COM.
220 Connection will close if idle more than 5 minutes.
501 OPTS unsuccessful; specified subcommand not recognized.
User (rch730a.rchland.ibm.com:(none)): mikswens
331 Enter password.
Password:
230 MIKSWENS logged on.
ftp> pwd
257 "/MIKSWENS" is current directory.
ftp> quote site namefmt 1
250 Now using naming format "1".
ftp> cd /mikswens
250 "/mikswens" is current directory.
ftp> asc
200 Representation type is ASCII nonprint.
ftp> get ebcdic.txt ascii.txt
200 PORT subcommand request successful.
150 Retrieving file /mikswens/ebcdic.txt
226 File transfer completed successfully.
ftp: 1128 bytes received in 0.00Seconds 1128000.00Kbytes/sec.
Connected to rch730a.rchland.ibm.com.
220-QTCP at RCH730A.RCHLAND.IBM.COM.
220 Connection will close if idle more than 5 minutes.
501 OPTS unsuccessful; specified subcommand not recognized.
User (rch730a.rchland.ibm.com:(none)): mikswens
331 Enter password.
Password:
230 MIKSWENS logged on.
ftp> pwd
257 "/MIKSWENS" is current directory.
ftp> quote site namefmt 1
250 Now using naming format "1".
ftp> cd /mikswens
250 "/mikswens" is current directory.
ftp> asc
200 Representation type is ASCII nonprint.
ftp> get ebcdic.txt ascii.txt
200 PORT subcommand request successful.
150 Retrieving file /mikswens/ebcdic.txt
226 File transfer completed successfully.
ftp: 1128 bytes received in 0.00Seconds 1128000.00Kbytes/sec.
Additional Information
There is an active request for enhancement (RFE) to Navigator for i to add conversion functionality. You can use the link to view, comment on, and vote for the request:
Document Location
Worldwide
[{"Type":"MASTER","Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"Platform":[{"code":"PF012","label":"IBM i"}],"Version":"7.1.0"}]
Was this topic helpful?
Document Information
Modified date:
22 June 2021
UID
ibm16207186