On operating systems that support UNICODE (Windows CE,
Symbian OS, Windows NT and Windows 2000), DB2 Everyplace takes UNICODE
strings only as Input/Output strings. These UNICODE strings are saved as UTF-8
format inside the DB2 Everyplace engine. A UNICODE character might require one to
three bytes of storage space after the UTF-8 conversion. A character
string stored in a database server such as IBM DB2 Universal Database might
require more space when the string is downloaded and stored in DB2 Everyplace on Windows
CE devices.
CLI UNICODE interface notes:
- The DB2 Everyplace CLI UNICODE functions have a character "W" appended at the
end. By defining the macro UNICODE (which is the system default on Windows
CE), the regular CLI functions map to the corresponding UNICODE functions
automatically. To write portable code, define the macro "UNICODE", and let
the system do the conversions.
- When UNICODE support is enabled, the data types SQL_C_CHAR, SQL_C_TCHAR,
and SQL_C_WCHAR have the same meaning.
- Many CLI functions have a string (or buffer) length as an input/output
parameter.
- For functions with Argument Type as SQLCHAR* (or SQLWCHAR* for
the W function), the length is the number of characters. For example:
SQLRETURN SQLExecDirect (SQLHSTMT hstmt,
SQLCHAR FAR *szSqlStr,
SQLINTEGER cbSqlStr);
UNICODE string L"ABCD" is four characters.
- For functions with Argument Type as SQLPOINTER, the length is
the number of bytes. For example:
SQLRETURN SQLGetData (SQLHSTMT hstmt,
SQLUSMALLINT icol,
SQLSMALLINT fCType,
SQLPOINTER rgbValue,
SQLINTEGER cbValueMax,
SQLINTEGER FAR *pcbValue);
The length
for the input parameter cbValueMax and output parameter *pcbValue are in bytes. UNICODE string L"ABCD" is eight bytes.
- The UNICODE functions can also take SQL_NTS to indicate a NULL-terminated
string.
Tips for writing portable code:
- Use SQLTCHAR instead of SQLCHAR or SQLWCHAR.
- Use the _tcsXXXX functions instead of strXXXX (ANSI) or wcsXXXX (UNICODE). For example, use _tcslen() instead of wcslen() or strlen().
- Use _TEXT() ( or TEXT() ) to wrap literal strings.
For example, _TEXT("ABCD") can be interpreted as either an ANSI
or UNICODE string depending on the macro definition.
- Use sizeof(ArrayName)/sizeof(TCHAR) to find out the size of
a character array.
For an example, see the Windows CE SampleCLP sample code included with DB2 Everyplace.
Related reference