Product Documentation

c-treeDB API for C++ - Developers Guide

Previous Topic

Next Topic

Writing UTF-16 Field Data

A new function ctdbSetFieldAsUTF16() has been added to c-treeDB C API to enable applications to write data to Unicode field types.

CTDBRET ctdbSetFieldAsUTF16(CTHANDLE Handle, NINT FieldNbr, pWCHAR pValue);

ctdbSetFieldAsUTF16() puts a Unicode UTF-16 string in a Unicode field. If the underlying field type is not one of the Unicode field types, the UTF-16 string is converted to the appropriate type before the data is stored in the field. Handle is a record handle, FieldNbr is the field number and pValue is a pointer to a wide (UTF-16) string buffer. ctdbSetFieldAsUTF16() returns CTDBRET_OK on success.

Two new methods, SetFieldAsUTF16(), have been added to the CTRecord class to enable applications to write data to Unicode field types.

void CTRecord::SetFieldAsUTF16(NINT FieldNumber, pWCHAR value);

SetFieldAsUTF16() puts a Unicode UTF-16 string in a Unicode field. If the underlying field type is not one of the Unicode field types, the UTF-16 string is converted to the appropriate type before the data is stored in the field. FieldNbr is a number representing the field number and value is the wide (UTF-16) string buffer.

void CTRecord::SetFieldAsUTF16(const CTString& FieldName, pWCHAR value);

SetFieldAsUTF16() puts a Unicode UTF-16 string in a Unicode field. If the underlying field type is not one of the Unicode field types, the UTF-16 string is converted to the appropriate type before the data is stores in the field. FieldName is the field name and value is the wide (UTF-16) string buffer.

Previous Topic

Next Topic

Writing UTF-16 Data C++ Example

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

{

WCHAR WStr[32];

hRecord.Clear();

ctdb_u8TOu16(str, WStr, sizeof(WStr));

hRecord.SetFieldAsUTF16(0, WStr);

hRecord.SetFieldAsSigned(1, (CTSIGNED)val);

hRecord.Write();

}

TOCIndex