Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

Unicode File Names

Virtually everywhere an ordinary ASCII file name is used with FairCom DB, a Unicode file name can be used. However, to use Unicode file names, the underlying OS platform must support file creation with Unicode file names. Also, FairCom DB requires that the file name have a special 8-byte prefix that informs FairCom DB about special file name encoding. Currently, FairCom DB accepts the use of UTF-8 and UTF-16 encoded Unicode file names. The ctMULTIBYTEname define enables this capability.

The following function stores a proper prefix at dp of type FnType.

NINT ctMBprefix(pTEXT dp,NINT FnType);

dp is a pTEXT because the name may be encoded as a byte stream or a wide character array, and ctMBprefix does not assume that dp is aligned when used with UTF-16. FnType may be ctFnTypeUTF8 or ctFnTypeUTF16. ctFnPrefixSIZE holds the size of the prefix in bytes. ctMBprefix returns NO_ERROR (0) unless the FnType parameter is bad, in which case BMOD_ERR (446) is returned.

In the following example, getUnicodeUTF8string() is assumed to be a routine which fills in a UTF-8 encoded string up to a maximum length. getUnicodeUTF16string() performs in the same manner with 16-bit wide characters.

FILNO datno8, datno16;

WCHAR utf16name[256];

TEXT utf8name[512];

ctMBprefix(utf8name,ctFnTypeUTF8);

getUnicodeUTF8string(utf8name + ctFnPrefixSIZE, 512 - ctFnPrefixSIZE);

datno8 = OPNRFIL(-1,utf8name,SHARED);

ctMBprefix((pTEXT) utf16name,ctFnTypeUTF16);

getUnicodeUTF16string(utf16name + ctFnPrefixSIZE / 2,

256 - ctFnPrefixSIZE / 2);

datno16 = OPNRFIL(-1,utf16name,SHARED);

Note: There is no provision for wide character encoded file name extents when using IFIL routines, such as CreateIFILXtd(), that permit the default file name extents to be overridden. It is possible to use UTF-8 encoded extents that will be properly merged with the root file names. However, there are only 8 bytes reserved for the extents, which effectively means at most 3 Unicode characters. Of course, it is possible to fully specify data and index names complete with extents if the dataextn and indxextn parameters to CreateIFILXtd() point to blank strings (i.e., “ ”), and if the aidxnam index name pointers (in the IIDX structures) specify the index file names complete with their extents.

TOCIndex