The ctdbGetFieldAsUTF16() function enables applications using the FairCom DB API C API to read data from Unicode field types.
CTDBRET ctdbGetFieldAsUTF16(CTHANDLE Handle, NINT FieldNbr, pWCHAR pValue, VRLEN size);
ctdbGetFieldAsUTF16() retrieves the field data as a Unicode UTF-16 string. If the underlying field type is not one of the Unicode field types, the data is converted to UTF-16 string. Handle is a record handle, FieldNbr is the number of the field, pValue is a pointer to a wide (UTF-16) string buffer and size indicates the size in bytes of the string area. ctdbGetFieldAsUTF16() returns CTDBRET_OK on success.
CTDBRET CheckData(CTHANDLE hRecord, pTEXT str, NINT val)
{
CTDBRET eRet;
WCHAR WStr[32];
TEXT s[64];
CTSIGNED t;
if ((eRet = ctdbGetFieldAsUTF16(hRecord, 0, WStr, sizeof(WStr))) != CTDBRET_OK)
{
printf("ctdbGetFieldAsUTF16 failed with error %d", eRet);
goto Exit;
}
if ((eRet = (CTDBRET)ctdb_u16TOu8(WStr, s, sizeof(s))) != CTDBRET_OK)
{
printf("ctdb_u16TOu8 failed with error %d", eRet);
goto Exit;
}
if (strcmp(s, str) != 0)
{
printf("UNICODE field contents not the same written");
eRet = CTDBRET_DIFFERENT;
goto Exit;
}
if ((eRet = ctdbGetFieldAsSigned(hRecord, 1, &t)) != CTDBRET_OK)
{
printf("ctdbGetFieldAsSigned failed with error %d", eRet);
goto Exit;
}
if ((NINT)t != val)
{
printf("integer field contents not the same written");
eRet = CTDBRET_DIFFERENT;
goto Exit;
}
if ((eRet = ctdbNextRecord(hRecord)) != CTDBRET_OK)
{
if (eRet == INOT_ERR)
eRet = CTDBRET_OK;
else
printf("ctdbNextRecord failed with error %d", eRet);
}
Exit:
return eRet;
}