Converting any file from one code page to another

  • Post category:Utilities
  • Reading time:1 mins read

The easiest way on z/OS to convert a file from one code page to another is to use the standard unix iconv utility.

The sample below is using a traditional batch job, but you can see it can just as easily be run from a shell environment or a shell script.

//STEP1    EXEC PGM=BPXBATCH                                   
//STDERR   DD SYSOUT=*                                         
//STDPARM  DD   *                                              
SH  iconv -f UTF-8 -t IBM-1140 inputfile.utf8 outputfile.ebcdic                
/*                                                             
//      ebcdic - Windows                                                       
SH  iconv -f IBM-1140 -t IBM-1252 inputfile.ebcdic outputfile.ibm1252            
//      Windows - ebcdic                                                        
SH  iconv -f IBM-1252 -t IBM-1140 inputfile.ibm1252 outputfile.ibm1140           
//      ebcdic - utf8                                                       
SH  iconv -f IBM-1140 -t UTF-8 inputfile.ebcdic outputfile.utf8                
//