Character strings

Describes coding conventions of the C API with respect to character strings.

You can pass character strings as parameters to various CPLEX routines, for example, as row or column names. The Interactive Optimizer truncates output strings 255 characters. Routines from the Callable Library truncate strings at 255 characters in output text files (such as MPS or LP text files) but not in binary SAV files. Routines from the Callable Library also truncate strings at 255 characters in names that occur in messages. Routines of the Callable Library that produce log files, such as the simplex iteration log file or the MIP node log file, truncate at 16 characters. Input, such as names read from LP and MPS files or typed interactively by the enter command, are truncated to 255 characters. However, it is not recommended that you rely on this truncation because unexpected behavior may result.

A string passed to CPLEX by your application as an argument of a Callable Library routine must be terminated by the NUL character. In other words, CPLEX recognizes NUL as the termination of a string that it accepts as an argument. This programming convention in C has implications for your choice of encoding. If you change the encoding of CPLEX from its default encoding ISO-8859-1 (also known as Latin-1) to a multi-byte encoding such as UTF-32, where a NULL byte can exist in the multi-byte representation of a character, then you must take care that a NULL byte within the multi-byte representation of a character does not unintentionally terminate a string passed to CPLEX as an argument. For an extended explanation of this point plus an example of how this situation can produce unintended results, see the topic Selecting an encoding, especially Example: hazardous encodings.