API string encoding switch
API string encoding switch
Purpose
API string encoding switch
|
Description
This parameter has no effect on IBM CPLEX Optimizer for z/OS, where only EBCDIC IBM-1047 encoding is available.
Which features does this parameter govern?
Generally, this parameter impacts names, such as the name of a model, the names of variables, the names of constraints, and other modeling elements. Also CPLEX respects this parameter (in the application programming interfaces (APIs) where the parameter is available) when CPLEX provides information (such as a log, a warning, an error message) on an output stream.
In the Callable Library
(C API), this parameter specifies the encoding in which CPLEX
passes a string to a function destination added to a channel by
means of the routine CPXaddfuncdest
.
In the C++ API, this parameter specifies
the encoding of streams accessed by the methods setWarning
and setOut
.
CPLEX also encodes exceptions according to the value of this
parameter.
This parameter is not available in the Python API where CPLEX relies on the native encoding.
This parameter is not available in the C#.NET API where CPLEX relies on the native encoding.
This parameter is not available in the Java API where CPLEX relies on the native encoding.
For a brief description of the advantages of UTF-8
,
see the topic Selecting an encoding in
the CPLEX User’s Manual.
Which values does this parameter accept?
This parameter accepts a string specifying the user’s choice of encoding, such as UTF-8, ISO-8859-1, US-ASCII, and so forth.
An asterisk (*) is an acceptable value in some situations. This wildcard instructs CPLEX to use the default converter according to the protocols and standards of International Components for Unicode (ICU). In other words, CPLEX calls ICU with a NULL encoding. When ICU is called with a NULL encoding (as in this case), ICU takes the name of the encoding from the terminal where the application started.
Other acceptable values of this parameter depend on the API.
-
In the Callable Library (C API), this parameter accepts any string that is the name of a valid code page supported by CPLEX. For example,
UTF-8
is a multi-byte encoding that is an acceptable value for this parameter; it encompasses the ASCII character set; it does not allow valid characters to include a NULL byte.For a complete list of valid strings that are the name of an encoding (that is, the name of a code page), consult the web site of a standards organization such as:
-
In the C++ API, the value of this parameter must be the name of an encoding that is a superset of ASCII. For example, ASCII is a subset of the encoding or code page
UTF-8
, soUTF-8
is an acceptable value for this parameter. Likewise, ASCII is a subset ofISO-8859-1
, also known asLatin-1
, soISO-8859-1
is an acceptable value for this parameter. However, the code pageUTF-16
is not acceptable, nor isUTF-32
because both allow valid characters that contain a NULL byte.
What is the default value of this parameter?
The default value of this parameter depends on the API.
-
In the C API, the default value is the string
ISO-8859-1
(also known as Latin-1). -
In the C++ API, the default value is the string
ISO-8859-1
(also known as Latin-1). -
In the CPLEX for MATLAB APIs, the default value is the asterisk (
*
).
The encoding ISO-8859-1
is a superset of
the familiar ASCII encoding, so it supports many widely used character
sets. However, this default encoding cannot represent multi-byte character
sets, such as Chinese, Japanese, Korean, Vietnamese, or Indian characters,
for example. If you want to represent a character set that requires
multiple bytes per character, then a better choice for the value of
this parameter is UTF-8
.
If you change the
value of this parameter, you must verify that your choice is compatible
with the file encoding switch
(CPXPARAM_Read_FileEncoding
, FileEncoding
).
In fact, the encoding or code page specified by the API encoding parameter
must be a subset of the encoding or code page specified by the file
encoding parameter. For example, if the value of the file encoding
parameter is UTF-8
, then US-ASCII
is
an acceptable value of the API encoding parameter because US-ASCII
is
a subset of UTF-8
. For examples of the hazards of
incompatible choices of the encoding parameters, see the topic Selecting an encoding in
the CPLEX User’s Manual.
What about errors?
In situations where CPLEX encounters a string, such as content in a file, that is not compatible with the specified encoding, the behavior is not defined. Because of the incompatibility, CPLEX silently converts the string to an inappropriate character of the specified encoding, or CPLEX raises the error 1235 CPXERR_ENCODING_CONVERSION. For an example of why such unpredictable behavior occurs, see the topic Selecting an encoding in the CPLEX User’s Manual.
Values
valid string for the name of an encoding (code page) that is a superset
of ASCII; default: ISO-8859-1
or empty string.
See also