UNICODE in Programming Languages
JDBC, ODBC and the C/C++ Precompiler support
UNICODE.JDBC
Since Java works with UNICODE strings, it can read and write UNICODE columns.
If you also want to use UNICODE in SQL statements, you must set the
unicode CONNECT-property to true. SQL statements are then transferred to the database instance in UTF-16/UCS-2 format. If the transfer package for the SQL statements is not large enough, you can increase its size using database parameter _PACKET_SIZE.ODBC
UNICODE is supported in the ODBC driver.
Depending on your operating system, you must take account of the following factors:
Operating system |
|
Windows NT/Windows 2000 |
The ODBC driver only exports the UNICODE and/or Wide functions of the ODBC-API. ANSI functions are mapped to the relevant Wide functions by the Windows Driver Manager . This means that applications can use both the ANSI and the UNICODE functions of the ODBC-API. |
UNIX/Linux |
The use of the ODBC driver is currently not possible on platforms for which the standard UNICODE type WCHAR_T is defined with four bytes. The database and ODBC driver process UNICODE internally as values that are two bytes long.Both the ANSI and UNICODE variants of the ODBC-API are defined in the driver. Applications that do not require the functionality of a Driver Manager can be statically linked with the ODBC driver. |
C/C++ Precompiler
During CONNECT, the C/C++ Precompiler checks whether the database is UNICODE-enabled (
Database parameter _UNICODE = YES). In UNICODE-enabled database, all SQL commands are transferred as UNICODE to the database instance.EXEC SQL BEGIN DECLARE SECTION;
/* "SELECT tablename FROM domain.tables" encoded in UCS2 */
SQLUCS2 sqlstmt[36] =
{0x0053, 0x0045, 0x004C, 0x0045, 0x0043,
0x0054, 0x0020, 0x0054, 0x0041, 0x0042,
0x004C, 0x0045, 0x004E, 0x0041, 0x004D,
0x0045, 0x0020, 0x0046, 0x0052, 0x004F,
0x004D, 0x0020, 0x0044, 0x004F, 0x004D,
0x0041, 0x0049, 0x004E, 0x002E, 0x0054,
0x0041, 0x0042, 0x004C, 0x0045, 0x0053,
0x0000};
SQLUCS2 resutlstring [64];
EXEC SQL END DECLARE SECTION;
/* connect ... */
/* parse a unicode SQL statement and give it a statement name */
EXEC SQL PREPARE stmt1 FROM :sqlstmt;
EXEC SQL DECLARE curs1 CURSOR FOR stm1;
EXEC SQL OPEN curs1;
/* loop over resultset */
WHILE (sqlca.sqlcode != 100)
{
EXEC SQL FETCH curs1 INTO :resultstring;
}
EXEC SQL CLOSE curs1;
For the complete example, see
Example 2 (HelloUnicodeDB.cpc).PYTHON, Perl
Python |
UNICODE not supported |
Planned for the end of 2001 |
Perl |
UNICODE not supported |
Planned for the end of 2001 |