Unicode function calls to ODBC driver managers
- Direct access - An application links to the CLI/ODBC driver
library and makes calls to exported CLI/ODBC functions.
Unicode applications accessing the CLI/ODBC driver
directly should access and perform transactions against the database
using the CLI Unicode
functions, and use SQLWCHAR buffers with the understanding that all
Unicode data is UCS-2. To identify itself as a Unicode application,
the application must connect to the database using either
SQLConnectW()orSQLDriverConnectW(). - Indirect access - An application links to an ODBC driver manager
library and makes calls to standard ODBC functions. The ODBC driver
manager then loads the CLI/ODBC driver
and calls exported ODBC functions on behalf of the application. The
data passed to the CLI/ODBC driver
from the application might be converted by the ODBC driver manager.
An application identifies itself to an ODBC driver manager as a Unicode
application by calling
SQLConnectW()orSQLDriverConnectW().
When connecting to a data source, the ODBC driver manager checks
to see if the requested driver exports the SQLConnectW() function.
If the function is supported, the ODBC driver is considered a Unicode
driver, and all subsequent calls in the application to ODBC functions
are routed to the functions' Unicode equivalents (identified by the
'W' suffix; for example, SQLConnectW()) by the ODBC
driver manager. If the application calls Unicode functions, no string
conversion is necessary, and the ODBC driver manager calls the Unicode
functions directly. If the application calls ANSI functions, the
ODBC driver manager converts all ANSI strings to Unicode strings before
calling the equivalent Unicode function.
If an application calls Unicode functions, but the driver does
not export SQLConnectW(), then the ODBC driver manager
routes any Unicode function calls to their ANSI equivalents. All Unicode
strings are converted by the ODBC driver manager to ANSI strings in
the application's code page before calling the equivalent ANSI function.
This might result in data loss if the application uses Unicode characters
which cannot be converted to the application's code page.
| Driver manager | Operating system | |
|---|---|---|
| Microsoft Windows | Linux and UNIX | |
| Microsoft ODBC Driver Manager | UTF-16* | not applicable |
| unixODBC Driver Manager | UCS-2 | UCS-2 |
| DataDirect Connect for ODBC Driver Manager | UTF-16* | UTF-8 |
| * UTF-16 is a superset of UCS-2 and therefore is compatible | ||