New datatypes and capabilities

To send and receive two-byte characters, the client specifies its preferred byte order during the login phase of the connection. Any necessary byte swapping is performed on the server site.

The Open Client ct_capability() parameters:

To access two-byte character data, Open Client/Open Server implements:

Setting the CS_DATAFMT parameter’s datatype to CS_UNICHAR_TYPE allows you to use existing API calls, such as ct_bind, ct_describe, ct_param, and so on.

CS_UNICHAR uses the format bitmask field of CS_DATAFMT to describe the destination format.

For example, in the Client Library sample program, rpc.c, the BuildRpcCommand() function contains the section of code that describes the datatype:

...
strcpy (datafmt.name, “@charparam”);
datafmt.namelen =CS_NULLTERM;
datafmt.datatype = CS_CHAR_TYPE;
datafmt.maxlength = CS_MAX_CHAR;
datafmt.status = CS_RETURN;
datafmt.locale = NULL;
...

In this example, from the new uni_rpc.c sample program, the character type is defined as datafmt.datatype = CS_CHAR_TYPE. Use an ASCII text editor to edit the datafmt.datatype field to:

...
strcpy (datafmt.name, “@charparam”);
datafmt.namelen =CS_NULLTERM;
datafmt.datatype = CS_UNICHAR_TYPE;
datafmt.maxlength = CS_MAX_CHAR;
datafmt.status = CS_RETURN;
datafmt.locale = NULL;
...

Since CS_UNICHAR is a UTF-16 encoded Unicode character datatype that is stored in two bytes, the maximum length of CS_UNICHAR string parameter sent to the server is restricted to one-half the length of CS_CHAR, which is stored in one-byte format.

The following table lists the CS_DATAFMT bitmask fields.

Table 2-8: CS_DATAFMT structure

Bitmask field

Description

CS_FMT_NULLTERM

The data is two-byte Unicode null-terminated (0x0000).

CS_FMT_PADBLANK

The data is padded with two-byte Unicode blanks to the full length of the destination variable (0x0020).

CS_FMT_PADNULL

The data is padded with two-byte Unicode nulls to the full length of the destination variable (0x0000).

CS_FMT_UNUSED

No format information is provided.