Programmer Guide : Working with Unicode : Developing applications for Unicode : ODBC applications and Unicode databases
  
ODBC applications and Unicode databases
In ODBC environments, the solidDB® ODBC driver handles the conversion of data between the encoding used in the application (client) and the UTF-8/UTF-16 format in the solidDB® Unicode database. The binding of character data can be set for all clients using the server-side parameter Srv.ODBCDefaultCharBinding or per client using the client-side parameter Client.ODBCCharBinding. In both cases, the standard C type identifier SQL_C_CHAR is used.
For binding of character data, you can set the ODBC driver to use one of the following methods:
the current client locale encoding
specific encoding as defined with a locale name
no encoding
UTF-8 encoding
Two use cases are supported for all methods:
The same binding method is set for all clients using the server-side parameter ODBCDefaultCharBinding.
[Srv]
ODBCDefaultCharBinding=raw|locale|locale:|locale:<locale name>|UTF8
The binding method is set per client by using the client-side parameter ODBCCharBinding.
[Client]
ODBCCharBinding=raw|locale|locale:<locale name>
The ODBCCharBinding parameter overrides the server-side settings set by ODBCDefaultCharBinding.
The factory value for both is locale:.
raw — no data conversion takes place between solidDB® server and the client
The value raw can be used when you want your database to use the binding used in the 6.3 or earlier versions of solidDB®.
locale — the current client locale setting is used, also if set by the client system
locale: — the current client setting are overridden with a default locale set of the client system
The driver calls setlocale() with an empty string which effectively searches for the locale setting set in the system.
For example, in Linux environments, the environmental variable LC_CTYPE is checked first and if that is not defined, the environmental variable LANG is searched.
locale:<locale name> — the current client systems setting are overridden and the given locale is used
The convention for <locale name> depends on the operating system.
For example, in Linux environments, the locale name for the code page GB18030 in Chinese/China is zh_CN.gb18030. In Windows environments, the locale name for Latin1 code page in Finnish/Finland is fin_fin.1252.
UTF8 — UTF-8 binding is enforced regardless of the locale set in the client-side system
Notes
If the value in Srv.ODBCDefaultCharBinding is other than locale, it overrides any current system locale setting for all clients.
If the value in Client.ODBCCharBinding is other than locale, it overrides both the server side value (if set) and the current system locale setting.
Using the current client locale encoding (locale)
To use the current client locale encoding:
1 Configure the parameter setting:
All clients use the same binding method (server-side parameter)
In the server-side solid.ini, section [Server], set the ODBCDefaultCharBinding parameter.
[Srv] ODBCDefaultCharBinding=locale
Some or all clients require different binding methods (client-side parameter)
In the client-side solid.ini, section [Client], set the ODBCCharBinding parameter.
[Client] ODBCCharBinding=locale
The client-side parameter overrides the server-side settings.
2 Set application to call setlocale().
Using a specific locale encoding (locale:<locale_name>)
To use a specific locale encoding:
Define the locale in solid.ini:
All clients use the same binding method (server-side parameter)
In the server-side solid.ini, section [Server], set the ODBCDefaultCharBinding parameter.
[Srv] ODBCDefaultCharBinding=locace:<locale name>
For example in Linux environments:
[Srv] ODBCDefaultCharBinding=locale:zh_CN.gb18030
Some or all clients require different binding methods (client-side parameter)
In the client-side solid.ini, section [Client], set the ODBCCharBinding parameter.
[Client] ODBCCharBinding=locale:<locale name>
The client-side parameter overrides the server-side settings.
For example in Linux environments:
[Client] ODBCCharBinding=locale:zh_CN.gb18030
Note Setting a specific locale overrides the application settings defined with setlocale().
Example 1
All clients use the current locale of the client. Different clients can use different code pages.
The server-side solid.ini is used:
[Srv]
ODBCDefaultCharBinding=locale
Example 2
Some clients use the current locale of the client, some clients use Latin1 code page:
The server-side solid.ini is used:
[Srv]
ODBCDefaultCharBinding=locale
In those clients that require the Latin1 code page, the client-side solid.ini is used:
[Client]
ODBCCharBinding=locale:fin_fin.1252
See also
Developing applications for Unicode