The support routines were changed to enable FairCom DB API to accept Unicode UTF-8 strings for names of objects such as databases, tables, fields, indexes, etc., and for path names used by the API.
For example, a table with name canção (a "song" in Portuguese) can be created with the following code.
Example
TEXT tableName[9] = {0x63, 0x61, 0x6e, 0xc3, 0xa7, 0xc3, 0xa3, 0x6f, 0x00};
If ((Retval = ctdbCreateTable(hTable, tableName, CTCREATE_NORMAL)) != CTDBRET_OK)
{
printf("ctdbCreateTable failed with error %d\n", eRet);
}
The bytes assigned to variable tableName is the UTF-8 representation of the Portuguese word canção.
If the original strings are encoded using UTF-16, you can use the FairCom DB API function, ctdb_u16TOu8(), to convert a UTF-16 string to a UTF-8 encoding. A UTF-8 string can also be converted back to UTF-16 by calling function ctdb_u8TOu16().
Example
CTDBRET OpenTable(CTHANDLE hTable, pWCHAR tableName)
{
CTDBRET Retval;
TEXT buffer[512];
if ((Retval = ctdb_u16TOu8(tableName, buffer, sizeof(buffer)) == CTDBRET_OK)
{
if ((Retval = ctdbOpenTable(hTable, buffer, CTOPEN_NORMAL)) != CTDBRET_OK)
printf("ctdbOpenTable failed with error %d\n", Retval);
}
else
printf("ctdb_u16TOu8 failed with error %d\n", Retval);
return Retval;
}