CHANGING THE CCSID OF A STREAM FILE
From time to time, you'll find a stream file in your IFS
that's marked with the wrong CCSID. I recently had a problem
where a file in my IFS was full of ASCII data but was marked
as CCSID 37 (US EBCDIC). This was a problem because the
IBM-supplied commands didn't convert the data, since they
thought it was already in EBCDIC.
The CHGATR command can be used to change the CCSID of a
stream file. Here's an example:
Another way to do the same thing is with the SETCCSID command
in QShell. Here's an example of that command:
If the data in the stream file also needs to be converted, you
can use QShell's ICONV command to convert it. This does not
set the CCSID of the resulting file properly, but we
already know how to fix that!
The following command converts the data in MYFILE.TXT from
CCSID 37 to CCSID 819 and writes the output to YOURFILE.TXT:
Another way to convert the data in the file is with the CPY CL command.
Here's an example of that:
From time to time, you'll find a stream file in your IFS
that's marked with the wrong CCSID. I recently had a problem
where a file in my IFS was full of ASCII data but was marked
as CCSID 37 (US EBCDIC). This was a problem because the
IBM-supplied commands didn't convert the data, since they
thought it was already in EBCDIC.
The CHGATR command can be used to change the CCSID of a
stream file. Here's an example:
Code:
CHGATR OBJ('/path/to/myfile.txt') ATR(*CCSID) VALUE(819)
in QShell. Here's an example of that command:
Code:
STRQSH CMD('setccsid 819 /path/to/myfile.txt')
can use QShell's ICONV command to convert it. This does not
set the CCSID of the resulting file properly, but we
already know how to fix that!
The following command converts the data in MYFILE.TXT from
CCSID 37 to CCSID 819 and writes the output to YOURFILE.TXT:
Code:
STRQSH CMD('iconv -f 37 -t 819 /path/to/myfile.txt > /path/to/yourfile.txt && setccsid 819 /path/to/yourfile.txt')
Here's an example of that:
Code:
CPY OBJ('/path/to/myfile.txt') TOOBJ('/path/to/yourfile.txt') + FROMCCSID(37) TOCCSID(819) DTAFMT(*TEXT)
Comment