[unixODBC-support] Length semantics

Nick Gorham nick.gorham at easysoft.com
Thu May 11 07:19:24 BST 2006

Vivekanand wrote:

> Nick,
> Thanks. I went through link you suggested and the article at 
> http://support.microsoft.com/kb/294169/en-us. I have some more queries.
> *1.* If the argument is string argument, then the corresponding length 
> is in characters which need not have to be an even number. Does this 
> imply that the string argument can not contain surrogate characters? 
> If that is the case, it can be a problem in some APIs. Consider 
> SQLExecDirectW() with INSERT query to be sent to a database server 
> which supports Unicode data in column with surrogate pairs. The query 
> is dynamically build in the application and contains surrogate pairs 
> in it. How can a driver determine the number of bytes / number of 
> codepoints in the query buffer if the query length is given in characters?

Thats why utf8 type unicode is a non started with ODBC, AFAIK, MS's view 
of UNICODE is 16 bit, and thats it, no surrogate pairs.

> *2.* /Ref.: This means that if the argument in question describes the 
> length of another argument that is always a string (typically 
> represented as a SQLCHAR), then the length reflects the number of 
> characters in the string. If the length argument describes another 
> argument that could be a string or some other data type (typically 
> represented as a SQLPOINTER), the length is in bytes./
> Does this apply for unixODBC too? I mean are the same semantics 
> followed for in case of utf16 and utf32 interfaces?

It certainly tries to, if I have got something wrong, let me know.


More information about the unixODBC-support mailing list