Product Documentation

c-treeDB API for C++ - Developers Guide

Previous Topic

Next Topic

Reading UTF-16 Field Data

Two methods, GetFieldAsUTF16(), were added to the CTRecord class to enable applications to read data from a Unicode field types.

By Field Number

GetFieldAsUTF16() 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 a UTF-16 string. FieldNumber is the number of the field, value is a pointer to a wide (UTF-16) string buffer and size indicates the size in bytes of the string area. Declaration:

void CTRecord::GetFieldAsUTF16(NINT FieldNumber, pWCHAR value, VRLEN size);

By Field Name

GetFieldAsUTF16() retrieves the field data as Unicode UTF-16 string. If the underlying field type is not one of the Unicode field types, the data is converted to a UTF-16 string. FieldName is a string object representing the field name, value is a pointer to a wide (UTF-16) string buffer and size indicates the size in bytes of the string area. Declaration:

void CTRecord::GetFieldAsUTF16(const CTString& FieldName, pWCHAR value, VRLEN size);

Previous Topic

Next Topic

Reading UTF-16 Data C++ Example

void CheckData(CTRecord& hRecord, const CTString& str, NINT val)

{

WCHAR WStr[32];

TEXT s[64];

CTSIGNED t;

hRecord.GetFieldAsUTF16(0, WStr, sizeof(WStr));

ctdb_u16TOu8(WStr, s, sizeof(s));

if (strcmp(s, str) != 0)

printf("UNICODE field contents not the same written");

t = hRecord.GetFieldAsSigned(1);

if ((NINT)t != val)

printf("integer field contents not the same written");

}

TOCIndex