Logo Search packages:      
Sourcecode: icu version File versions

U_STABLE void U_EXPORT2 u_setDataDirectory ( const char *  directory  ) 

Set the ICU data directory. The data directory is where common format ICU data files (.dat files) are loaded from. Note that normal use of the built-in ICU facilities does not require loading of an external data file; unless you are adding custom data to ICU, the data directory does not need to be set.

This function should be called at most once in a process, before the first ICU operation (e.g., u_init()) that will require the loading of an ICU data file. This function is not thread-safe. Use it before calling ICU APIs from multiple threads.

directory The directory to be set.
See also:
u_init ICU 2.0

Definition at line 1031 of file putil.c.

References NULL, and U_FILE_SEP_CHAR.

    char *newDataDir;
    int32_t length;

    if(directory==NULL || *directory==0) {
        /* A small optimization to prevent the malloc and copy when the
        shared library is used, and this is a way to make sure that NULL
        is never returned.
        newDataDir = (char *)"";
    else {
        newDataDir = (char *)uprv_malloc(length + 2);
        /* Exit out if newDataDir could not be created. */
        if (newDataDir == NULL) {
        uprv_strcpy(newDataDir, directory);

            char *p;
            while(p = uprv_strchr(newDataDir, U_FILE_ALT_SEP_CHAR)) {
                *p = U_FILE_SEP_CHAR;

    if (gDataDirectory && *gDataDirectory) {
    gDataDirectory = newDataDir;
    ucln_common_registerCleanup(UCLN_COMMON_PUTIL, putil_cleanup);

Generated by  Doxygen 1.6.0   Back to index