Product Documentation

c-treeDB API for C++ - Developers Guide

Previous Topic

Next Topic

c-treeDB C++ API UTF-8 Compliance

The support routines were changed to enable c-treeDB 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.

Example

For example, a table with name canção (a "song" in Portuguese) can be created with the following code:

TEXT tableName[9] = {0x63, 0x61, 0x6e, 0xc3, 0xa7, 0xc3, 0xa3, 0x6f, 0x00};

ctTable->Create(tableName, CTCREATE_NORMAL);

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 c-treeDB 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

CTTable* OpenTable(pWCHAR tableName)

{

CTTable *ctTable = new CTTable(ctDB);

CTString name(tableName);

ctTable->Open(name, CTOPEN_NORMAL);

Return ctTable;

}

TOCIndex