michael@0: /*
michael@0: ******************************************************************************
michael@0: *
michael@0: * Copyright (C) 1997-2011, International Business Machines
michael@0: * Corporation and others. All Rights Reserved.
michael@0: *
michael@0: ******************************************************************************
michael@0: *
michael@0: * FILE NAME : putil.h
michael@0: *
michael@0: * Date Name Description
michael@0: * 05/14/98 nos Creation (content moved here from utypes.h).
michael@0: * 06/17/99 erm Added IEEE_754
michael@0: * 07/22/98 stephen Added IEEEremainder, max, min, trunc
michael@0: * 08/13/98 stephen Added isNegativeInfinity, isPositiveInfinity
michael@0: * 08/24/98 stephen Added longBitsFromDouble
michael@0: * 03/02/99 stephen Removed openFile(). Added AS400 support.
michael@0: * 04/15/99 stephen Converted to C
michael@0: * 11/15/99 helena Integrated S/390 changes for IEEE support.
michael@0: * 01/11/00 helena Added u_getVersion.
michael@0: ******************************************************************************
michael@0: */
michael@0:
michael@0: #ifndef PUTIL_H
michael@0: #define PUTIL_H
michael@0:
michael@0: #include "unicode/utypes.h"
michael@0: /**
michael@0: * \file
michael@0: * \brief C API: Platform Utilities
michael@0: */
michael@0:
michael@0: /*==========================================================================*/
michael@0: /* Platform utilities */
michael@0: /*==========================================================================*/
michael@0:
michael@0: /**
michael@0: * Platform utilities isolates the platform dependencies of the
michael@0: * libarary. For each platform which this code is ported to, these
michael@0: * functions may have to be re-implemented.
michael@0: */
michael@0:
michael@0: /**
michael@0: * Return the ICU data directory.
michael@0: * The data directory is where common format ICU data files (.dat files)
michael@0: * are loaded from. Note that normal use of the built-in ICU
michael@0: * facilities does not require loading of an external data file;
michael@0: * unless you are adding custom data to ICU, the data directory
michael@0: * does not need to be set.
michael@0: *
michael@0: * The data directory is determined as follows:
michael@0: * If u_setDataDirectory() has been called, that is it, otherwise
michael@0: * if the ICU_DATA environment variable is set, use that, otherwise
michael@0: * If a data directory was specifed at ICU build time
michael@0: *
michael@0: * \code
michael@0: * #define ICU_DATA_DIR "path"
michael@0: * \endcode
michael@0: *
use that,
michael@0: * otherwise no data directory is available.
michael@0: *
michael@0: * @return the data directory, or an empty string ("") if no data directory has
michael@0: * been specified.
michael@0: *
michael@0: * @stable ICU 2.0
michael@0: */
michael@0: U_STABLE const char* U_EXPORT2 u_getDataDirectory(void);
michael@0:
michael@0: /**
michael@0: * Set the ICU data directory.
michael@0: * The data directory is where common format ICU data files (.dat files)
michael@0: * are loaded from. Note that normal use of the built-in ICU
michael@0: * facilities does not require loading of an external data file;
michael@0: * unless you are adding custom data to ICU, the data directory
michael@0: * does not need to be set.
michael@0: *
michael@0: * This function should be called at most once in a process, before the
michael@0: * first ICU operation (e.g., u_init()) that will require the loading of an
michael@0: * ICU data file.
michael@0: * This function is not thread-safe. Use it before calling ICU APIs from
michael@0: * multiple threads.
michael@0: *
michael@0: * @param directory The directory to be set.
michael@0: *
michael@0: * @see u_init
michael@0: * @stable ICU 2.0
michael@0: */
michael@0: U_STABLE void U_EXPORT2 u_setDataDirectory(const char *directory);
michael@0:
michael@0: /**
michael@0: * @{
michael@0: * Filesystem file and path separator characters.
michael@0: * Example: '/' and ':' on Unix, '\\' and ';' on Windows.
michael@0: * @stable ICU 2.0
michael@0: */
michael@0: #if U_PLATFORM == U_PF_CLASSIC_MACOS
michael@0: # define U_FILE_SEP_CHAR ':'
michael@0: # define U_FILE_ALT_SEP_CHAR ':'
michael@0: # define U_PATH_SEP_CHAR ';'
michael@0: # define U_FILE_SEP_STRING ":"
michael@0: # define U_FILE_ALT_SEP_STRING ":"
michael@0: # define U_PATH_SEP_STRING ";"
michael@0: #elif U_PLATFORM_USES_ONLY_WIN32_API
michael@0: # define U_FILE_SEP_CHAR '\\'
michael@0: # define U_FILE_ALT_SEP_CHAR '/'
michael@0: # define U_PATH_SEP_CHAR ';'
michael@0: # define U_FILE_SEP_STRING "\\"
michael@0: # define U_FILE_ALT_SEP_STRING "/"
michael@0: # define U_PATH_SEP_STRING ";"
michael@0: #else
michael@0: # define U_FILE_SEP_CHAR '/'
michael@0: # define U_FILE_ALT_SEP_CHAR '/'
michael@0: # define U_PATH_SEP_CHAR ':'
michael@0: # define U_FILE_SEP_STRING "/"
michael@0: # define U_FILE_ALT_SEP_STRING "/"
michael@0: # define U_PATH_SEP_STRING ":"
michael@0: #endif
michael@0:
michael@0: /** @} */
michael@0:
michael@0: /**
michael@0: * Convert char characters to UChar characters.
michael@0: * This utility function is useful only for "invariant characters"
michael@0: * that are encoded in the platform default encoding.
michael@0: * They are a small, constant subset of the encoding and include
michael@0: * just the latin letters, digits, and some punctuation.
michael@0: * For details, see U_CHARSET_FAMILY.
michael@0: *
michael@0: * @param cs Input string, points to length
michael@0: * character bytes from a subset of the platform encoding.
michael@0: * @param us Output string, points to memory for length
michael@0: * Unicode characters.
michael@0: * @param length The number of characters to convert; this may
michael@0: * include the terminating NUL
.
michael@0: *
michael@0: * @see U_CHARSET_FAMILY
michael@0: * @stable ICU 2.0
michael@0: */
michael@0: U_STABLE void U_EXPORT2
michael@0: u_charsToUChars(const char *cs, UChar *us, int32_t length);
michael@0:
michael@0: /**
michael@0: * Convert UChar characters to char characters.
michael@0: * This utility function is useful only for "invariant characters"
michael@0: * that can be encoded in the platform default encoding.
michael@0: * They are a small, constant subset of the encoding and include
michael@0: * just the latin letters, digits, and some punctuation.
michael@0: * For details, see U_CHARSET_FAMILY.
michael@0: *
michael@0: * @param us Input string, points to length
michael@0: * Unicode characters that can be encoded with the
michael@0: * codepage-invariant subset of the platform encoding.
michael@0: * @param cs Output string, points to memory for length
michael@0: * character bytes.
michael@0: * @param length The number of characters to convert; this may
michael@0: * include the terminating NUL
.
michael@0: *
michael@0: * @see U_CHARSET_FAMILY
michael@0: * @stable ICU 2.0
michael@0: */
michael@0: U_STABLE void U_EXPORT2
michael@0: u_UCharsToChars(const UChar *us, char *cs, int32_t length);
michael@0:
michael@0: #endif