Product Documentation

FairCom DB API for C

Previous Topic

Next Topic

ctdbGetFieldAsUTF16

Retrieves the field data as a Unicode UTF-16 string.

Declaration

CTDBRET ctdbGetFieldAsUTF16(CTHANDLE Handle, NINT FieldNbr, pWCHAR pValue, VRLEN size);

Description

ctdGetFieldAsUTF16() 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 strings. 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.

Return

Value

Symbolic Constant

Explanation

0

NO_ERROR

No error occurred.

See Appendix A for a complete listing of valid c-tree Plus error values.

Example

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;

}

Exit:

return eRet;

}

See Also

ctdbSetFieldAsUTF16()

TOCIndex