IBM Support

Data conversions in CGI programs

News


Abstract

Data conversions in CGI programs

Content

You are in: IBM i Technology Updates  > Web Integration on i IBM HTTP Server for i > Introduction > Data conversions in CGI programs

This page lists information about CGI output mode data conversions.

Data conversions in CGI programs

The server can perform ASCII to EBCDIC conversions before sending data to CGI programs. This is because the Internet is an ASCII world and the iSeries is primarily an extended binary-coded decimal interchange code (EBCDIC) world. The server can also perform EBCDIC to ASCII conversions before sending data back to the browser. You must provide data to a CGI program through environment variables and standard-input (stdin). HTTP and HTML specifications allow you to tag text data with a character set (charset parameter on the Content-Type header). However, this practice is not widely in use today (although technically required for HTTP1.0/1.1 compliance). According to this specification, text data that is not tagged can be assumed to be in the default character set ISO-8859-1 (US-ASCII). iSeries correlates this character set with ASCII CCSID 819.  

There are basically three different ways the server can process the input to your CGI program. You can configure the server to control which mode is used by specifying the CGIConvMode directive.

Where CGIConvMode is one of the following :

EBCDIC - This is the default.

EBCDIC_JCD

BINARY 

In addition, the system provides the following CGI environment variables to the CGI program: 

  • CGI_MODE - which input conversion mode the server is using (EBCDIC or EBCDIC_JCD or BINARY)  
  • CGI_ASCII_CCSID - the ASCII CCSID used to convert the data  
  • CGI_EBCDIC_CCSID - the EBCDIC CCSID used to convert the data  
  • CGI_OUTPUT_MODE - which output conversion mode the server is using (EBCDIC or BINARY)

So, for the input mode, the following occurs:  

EBCDIC - the system converts environment variables and stdin data, including escape sequences, to the CCSID of the job.

EBCDIC_JCD - same as EBCDIC except for servers running under a Japanese CCSID. Servers running under a Japanese CCSID use the JCD utility to determine which Japanese CCSID to use to convert from.  

BINARY - the server performs no conversion for stdin data and QUERY_STRING; all other environment variables are in the CCSID of the job.

CGI conversion modes

The following section explains CGI input conversion modes in more detail.  

EBCDIC 

In this mode, the server will convert everything into the EBCDIC CCSID of the job. The server checks the Entity bodies for a charset tag. If found, the server will convert the corresponding ASCII CCSID to the EBCDIC CCSID of the job. If the server does not find a charset tag, it uses the value of the DefaultNetCCSID configuration directive as the conversion CCSID. In addition, the system converts escaped octets from ASCII to EBCDIC, eliminating the need to perform this conversion in the CGI program.

BINARY 

In this mode, the server processes environment variables (except QUERY_STRING) the same way as EBCDIC mode. The server performs no conversions on either QUERY_STRING or stdin data.

EBCDIC_JCD 

Japanese browsers can potentially send data in one of three code pages, JIS (ISO-2022-JP), S-JIS (PC-Windows), or EUC (UNIX). In this mode, the server uses a well-known JCD utility to determine which codepage to use (if not explicitly specified by a charset tag) to convert stdin data.

Conversion action for text in CGI Stdin

This table summarizes the type of conversion that is performed by the server for each CGI mode.  

Note: Starting in V5R4, it is possible to set the ASCII and EBCDIC CCSIDs for a CGI job in a container context (

DefaultNetCCSID
and
CGIJobCCSID

directives.) In this table, CGI job CCSID means the CCSID used to start the CGI job. Starting in V5R4, the CGI job CCSID will be set from the global FsCCSID unless there is a CGI job CCSID within the CGI container context.

[{"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"Component":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]

Document Information

Modified date:
30 January 2020

UID

ibm11171090