Previous Topic

Next Topic

ctMBprefix

Stores a proper prefix to a Unicode filename string.

Short Name

ctMBprefix()

Type

Utility

Declaration

NINT ctMBprefix(pTEXT dp, NINT FnType)

Description

c-tree Plus requires that the Unicode file name have a special 8-byte prefix that informs c-tree Plus about special file name encoding. ctMBprefix() stores a proper prefix at dp of type 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 UTF16.

FnType may be ctFnTypeUTF8 or ctFnTypeUTF16. Both of these constants are defined in ctport.h. ctFnPrefixSIZE holds the size of the prefix in bytes.

Return

Value

Symbolic Constant

Explanation

0

NO_ERROR

Prefix stored.

446

BMOD_ERR

FnType parameter is bad.

See c-tree Plus Error Codes for a complete listing of valid c-tree Plus error values.

Example

/* In the following example, getUnicodeUTF8string is assumed to be a routine 
   which will fill-in a UTF8 encoded string up to a max length.
   GetUnicodeUTF16string performs in the same manner except that it works with
   16 bit wide characters.
*/

COUNT 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);