chcp - Set or query ASCII/EBCDIC code pages for the terminal
- chcp [-r | -q]
- chcp [-s] [-a ASCII_cp] [-e EBCDIC_cp]
chcp sets, resets, or queries the current ASCII/EBCDIC code conversion in effect for the controlling terminal. Use it when the terminal requires ASCII data and the shell application uses EBCDIC. Do not use chcp if you are logged on through the TSO/E OMVS command. The _BPX_TERMPATH environment variable enables shell scripts to tell if the user logged on from TSO, rather from rlogin or telnet.
- -a ASCII_cp
- The name of the ASCII code page used by the terminal. EBCDIC data from the shell application is
converted to this ASCII code page before it is sent out to the terminal. Data from the terminal is
converted from this ASCII code page to EBCDIC before the application receives it.
The name of the ASCII code page is case-sensitive.
- -e EBCDIC_cp
- The name of the EBCDIC code page used for this session. EBCDIC data from the shell application
is converted from this EBCDIC code page to ASCII before it is sent out to the terminal. ASCII data
from the terminal is converted to this EBCDIC code page before the application receives it.
The name of the EBCDIC code page is case-sensitive.
- Queries the current ASCII and EBCDIC code pages for this terminal. The results are written to standard output. You cannot use any other options if you use the -q option.
- Resets the ASCII/EBCDIC conversion for the terminal to the default code pages. The default ASCII
code page is ISO8859-1, and the default EBCDIC code page is IBM-1047.
You cannot use -q with any other options.
- Specifies that the ASCII/EBCDIC conversion for the terminal is to use the code pages specified by the -a and -e options. You cannot use -s with any other options other than -a or -e. Either -a or -e (or both) must also be specified if -s is used.
You get the following output:
Current ASCII code page = ISO8859-1 Current EBCDIC code page = IBM-1047
- To set the ASCII and EBCDIC code pages to IBM-eucJP and IBM-939, enter:
chcp -a IBM-eucJP -e IBM-939
- To change just the EBCDIC code page to IBM-277, enter:
chcp -se IBM-277
- To change just the ASCII code page to IBM-850, enter:
chcp -a IBM-850
- To reset ASCII/EBCDIC code page conversion to the default code pages for this terminal, enter:
- To query the current ASCII and EBCDIC code pages for this terminal, enter:
- Do not use chcp when you are logged on from the TSO/E OMVS command
because the OMVS command does not do any ASCII/EBCDIC code page conversion.
Shell scripts can test the _BPX_TERMPATH environment variable and bypass chcp when the user is logged on through OMVS. (The _BPX_TERMPATH environment variable enables shell scripts to tell if the user logged on from TSO/E rather than from rlogin or telnet.)
Before starting the session, the TSO/E OMVS command sets _BPX_TERMPATH to OMVS.Sample shell script code:
# ----------------------------------------------- # Issue chcp only if not using TSO/E OMVS command # ----------------------------------------------- if test "$_BPX_TERMPATH" != "OMVS" then chcp -a IBM-850 -e IBM-047 fi
- After running chcp -s to change the EBCDIC code page for the session, you may
also need to alter or set the following environment variables to match the new code page:
- The code page names supplied with the -a and -e options are passed to iconv_open() without any uppercase or lowercase conversion. Code page converters that convert between the specified ASCII and EBCDIC code pages must be available for iconv().
- If ASCII/EBCDIC conversion is not active for this terminal, both the ASCII and EBCDIC code pages must be specified on the chcp -s command. At other times, omit -a when just the EBCDIC code page needs to be changed. Omit -e when just the ASCII code page needs to be changed.
- All code pages with names not known to chcp are considered to be single-byte (SBCS) user-defined code pages. User-defined multibyte code pages are not supported.
- chcp cannot check user-defined code page names to make sure that -a really specifies an ASCII code page and -e specifies an EBCDIC code page. In this case, specifying the wrong code pages may cause terminal input and output to be completely unreadable. It may also be impossible to enter any more shell commands.
- chcp operates on the controlling terminal.
- chcp should not be run as a background job.
- The -d option specifies that special debugging information be printed. Specify this option only when requested by IBM®.
- Successful completion.
- Incorrect command-line arguments or options.
- Any of the following errors:
- There is no controlling terminal.
- The controlling terminal does not support ASCII/EBCDIC code page conversion (the TSO/E OMVS command, for example).
- iconv_() fails when passed the code page names specified on the command line.
- chcp cannot build SBCS conversion tables using iconv() when required.
- An I/O error occurred on the controlling terminal.
- Either the -a or -e was omitted and the chcp -s command was run while the terminal code page conversion is in binary mode.
None. chcp is not described in any standard.