informix
Informix Guide to GLS Functionality
Informix ESQL/C Features

Handling Non-ASCII Characters

The ESQL/C processors obtain the code set for use in ESQL/C source files from the client locale. Within an ESQL/C source file, you can use non-ASCII characters for the following objects:

To use non-ASCII characters in your ESQL/C source file, the client locale must support them. For information about the use of non-ASCII characters, see Non-ASCII Characters in Identifiers.

Using Non-ASCII Characters in Host Variables

ESQL/C allows the use of non-ASCII characters in host variables when the following conditions are true:

ESQL/C applications can also support non-ASCII characters in comments and SQL identifiers. For more information, see Non-ASCII Characters in Identifiers.

The following code fragment declares an integer host-variable that contains a non-ASCII character in the host-variable name and then selects a serial value into this variable:

If the client locale supports the non-ASCII characters, you can use these characters to define indicator variables, as the following example shows:

You can then access indicator variables with these non-ASCII names, as the following example shows:

Generating Non-ASCII Filenames

When an ESQL/C source file is processed, the ESQL/C processor generates a corresponding intermediate file for the source file. If you use non-ASCII characters (8-bit and multibyte character) in these source filenames, the following restrictions affect the ability of the ESQL/C processor to generate filenames that contain 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.

However, the capabilities of your C compiler 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.

After esqlmf filters the ESQL/C source file, the C compiler sees this line as follows:

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:

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 6-1 shows how an ESQL/C program that contains non-ASCII characters becomes an executable program.

Figure 6-1
Creating an ESQL/C Executable Program from a Non-ASCII Source 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:

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 Value 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)
  3. Before esqlmf begins filtering, it creates a copy of the C source file (source.c) that has the .c_ file extension (source.c_).

  4. Compiles the filtered C source file (source.c) with the C compiler to create an object file (source.o)
  5. 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, 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.


Informix Guide to GLS Functionality, Version 9.2
Copyright © 1999, Informix Software, Inc. All rights reserved