The ODBC driver supports conversions of XML values to and from both ODBC Character C types (SQL_C_CHAR and SQL_C_WCHAR) and the Binary C type SQL_C_BINARY.
The recommended conversion of XML is to or from SQL_C_BINARY or SQL_C_WCHAR because it eliminates conversion to a non-Unicode code page used by the application, which can result in conversion errors. The default ODBC C type for SQL_TD_XML is SQL_C_BINARY. SQL_TD_XML values represented as ODBC C types are listed below.
|XML represented as||Description|
|SQL_C_BINARY||The value is a sequence of characters encoded in UTF8 regardless of any encoding declaration in the XML text.|
|SQL_C_CHAR||The value is a sequence of characters encoded in the application code page regardless of any encoding declaration in the XML text.|
|SQL_C_WCHAR||The value is a sequence of characters encoded in the Unicode encoding in effect for the application (UTF8 or UTF16 for Linux/Unix. UTF16 for Windows, UTF32 for Apple OS X). The encoding is independent of any encoding declaration in the XML text.|
For a given XML document the recommended ODBC C type for working with the document in ODBC depends on the XML document encoding as determined by the XML declaration in the document. Recommended ODBC C types for XML document encoding are listed below.
|XML Document Encoding Declaration||Recommended ODBC C type for working with the document in an ODBC application|
|Windows||Linux/Unix||Apple OS X|
|UTF8||SQL_C_BINARY or SQL_C_WCHAR. Note that when using SQL_C_WCHAR the encoding will be UTF16||SQL_C_BINARY or SQL_C_WCHAR.||SQL_C_BINARY or SQL_C_WCHAR|
|UTF16||SQL_C_WCHAR||SQL_C_WCHAR with UTF16 Unicode encoding as described in Unicode Character Types.||SQL_C_WCHAR|
|Other||SQL_C_CHAR using application code page matching document encoding||SQL_C_CHAR using an application code page matching the XML document encoding.||SAL_C_CHAR with locale LC_TYPE setting matching the document encoding.|