DB2 10.5 for Linux, UNIX, and Windows

Unicode functions (CLI)

CLI Unicode functions accept Unicode string arguments in place of ANSI string arguments. The Unicode string arguments must be in UCS-2 encoding (native-endian format).
ODBC API functions have suffixes to indicate the format of their string arguments: those that accept Unicode end in W, and those that accept ANSI have no suffix (ODBC adds equivalent functions with names that end in A, but these are not offered by CLI). The following list of CLI functions are available in both ANSI and Unicode versions:

For unicode functions that take a string length as an argument, the length is calculated as the number of SQL_WCHAR elements that are needed to store the string. For unicode functions that return string data from the server, the returned length of the string data is the number of SQL_WCHAR elements that are needed to store the string. However, the length of data that can be a string or non-string is calculated in number of bytes that are needed to store the data.

For example, the SQLGetInfoW() API takes the length as the number of bytes while the SQLExecDirectW() function interprets the length as the number of SQL_WCHAR elements. On Windows operating systems, where the UTF-16 extended character set is used, the single character SQL_WCHAR is equivalent to 2 SQL_C_CHAR elements. Each SQL_C_CHAR element has length of 2 bytes. The CLI driver returns data from the result sets in either unicode or ANSI, depending on the API called by the application and the data that are bound. If an application binds data to a SQL_C_CHAR type, the CLI driver converts SQL_WCHAR data to SQL_CHAR in the unicode function.

ANSI to Unicode function mappings

The syntax for a CLI Unicode function is the same as the syntax for its corresponding ANSI function, except that SQL_CHAR parameters are defined as SQL_WCHAR. Character buffers defined as SQLPOINTER in the ANSI syntax can be defined as either SQL_CHAR or SQL_WCHAR in the unicode function.