The ESQL/C processor, esql, accepts C source programs that are written in the client code set (the code set of the client locale). The ESQL/C preprocessor, esqlc, can accept non-ASCII characters (8-bit and multibyte) in the ESQL/C source code as long as the client code set defines them.
The capabilities of your C compiler, however, might limit your ability to use non-ASCII characters within an ESQL/C source file. If the C compiler does not fully support non-ASCII characters, it might not successfully compile an ESQL/C program that contains these characters. To provide support for common non-ASCII limitations of C compilers, ESQL/C provides an ESQL/C filter that is called esqlmf.
This section provides the following information about the ESQL/C filter:
As part of the compilation process of an ESQL/C source program, the ESQL/C processor calls the C compiler. When you develop ESQL/C source code that contains non-ASCII characters, the way that the C compiler handles such characters can affect the success of the compilation process. In particular, the following situations might affect compilation of your ESQL/C program:
A component of a multibyte character might be indistinguishable from some single-byte characters such as percent ( % ), comma ( , ), backslash ( \ ), and double quote ( " ) characters. If such characters are included in a quoted string, the C compiler might interpret them as C-language tokens, which can cause compilation errors or even lost characters.
If a code set contains non-ASCII characters (with code values that are greater than 127), the C compiler must be 8-bit clean to interpret the characters. To be 8-bit clean, a compiler must read the eighth bit as part of the code value; it must not ignore or put its own interpretation on the meaning of this eighth bit.
To filter a non-ASCII character, the ESQL/C filter converts each byte of the character to its octal equivalent. For example, suppose the multibyte character A1A2A3 has an octal representation of \160\042\244 and appears in the stcopy() call.
stcopy("A1A2A3", dest);
After esqlmf filters the ESQL/C source file, the C compiler sees this line as follows:
stcopy("\160\042\244", dest); /* correct interpretation */
To handle the C-language-token situation, the filter prevents the C compiler from interpreting the A2 byte (octal \042) as an ASCII double quote and incorrectly parsing the line as follows:
stcopy("A1"A3, dest); /* incorrect interpretation of A2 */
The C compiler would generate an error for the preceding line because the line has terminated the string argument incorrectly. The esqlmf utility also handles the 8-bit-clean situation because it prevents the C compiler from ignoring the eighth bit of the A3 byte. If the compiler ignores the eighth bit, it incorrectly interprets A3 (octal \244) as octal \044.
Figure 5 shows how an ESQL/C program that contains non-ASCII characters becomes an executable program.
The esql command can automatically call the ESQL/C filter, esqlmf, to process non-ASCII characters. When you set the following environment variables, you tell esql how to invoke esqlmf:
When you set ESQLMF to 1, esql automatically calls esqlmf after the ESQL/C preprocessor and before the C compiler.
Set CC8BITLEVEL to indicate the ability of your C compiler to process non-ASCII characters.
How esqlmf filters an ESQL/C source file depends on the value of the CC8BITLEVEL environment variable. For each value of CC8BITLEVEL, the following table shows the esqlmf command that the ESQL/C processor invokes on a ESQL/C source file.
CC8BITLEVEL | esqlmf Action |
---|---|
0 | Converts all non-ASCII characters, in literal strings and comments, to octal constants. |
1 | Converts non-ASCII characters in literal strings, but not in comments, to octal constants. |
2 | Converts non-ASCII characters in literal strings to octal constants to ensure that all the bytes in the non-ASCII characters have the eighth bit set. |
3 | Does not invoke esqlmf. |
When you set CC8BITLEVEL to 0, 1, or 2, the ESQL/C processor performs the following steps:
Before esqlmf begins filtering, it creates a copy of the C source file (source.c) that has the .c_ file extension (source.c_).
When you set CC8BITLEVEL to 3, the ESQL/C processor omits step 2 in the preceding list.
If you do not set CC8BITLEVEL, then esql converts non-ASCII characters in literal strings and comments. You can modify the value of CC8BITLEVEL to reflect the capabilities of your C compiler.
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]