Home | Previous Page | Next Page   IBM Informix ESQL/C Features (ESQL/C) > Handling Non-ASCII Characters >

Using Non-ASCII Characters in ESQL/C Source Files

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:

Filtering Non-ASCII Characters

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:

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.

Invoking the ESQL/C Filter

Figure 5 shows how an ESQL/C program that contains non-ASCII characters becomes an executable program.

Figure 5. Creating an ESQL/C Executable Program from a Non-ASCII Source Program
begin figure description - This figure is described in the surrounding text. - end figure description

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:

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.

Important:
To invoke the esqlmf commands that CC8BITLEVEL can specify, you must set the ESQLMF environment variable to 1.

When you set CC8BITLEVEL to 0, 1, or 2, the ESQL/C processor performs the following steps:

  1. Converts the embedded-language statements (source.ec) to C-language source code (source.c) with the ESQL/C preprocessor
  2. Filters non-ASCII characters in the preprocessed file (source.c) with the ESQL/C filter, esqlmf (if the ESQLMF environment variable is 1)

    Before esqlmf begins filtering, it creates a copy of the C source file (source.c) that has the .c_ file extension (source.c_).

  3. Compiles the filtered C source file (source.c) with the C compiler to create an object file (source.o)
  4. Links the object file with the ESQL/C libraries and your own libraries to create an executable program

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 ]