1/* 2****************************************************************************** 3* 4* Copyright (C) 1997-2011, International Business Machines 5* Corporation and others. All Rights Reserved. 6* 7****************************************************************************** 8* 9* FILE NAME : putil.h 10* 11* Date Name Description 12* 05/14/98 nos Creation (content moved here from utypes.h). 13* 06/17/99 erm Added IEEE_754 14* 07/22/98 stephen Added IEEEremainder, max, min, trunc 15* 08/13/98 stephen Added isNegativeInfinity, isPositiveInfinity 16* 08/24/98 stephen Added longBitsFromDouble 17* 03/02/99 stephen Removed openFile(). Added AS400 support. 18* 04/15/99 stephen Converted to C 19* 11/15/99 helena Integrated S/390 changes for IEEE support. 20* 01/11/00 helena Added u_getVersion. 21****************************************************************************** 22*/ 23 24#ifndef PUTIL_H 25#define PUTIL_H 26 27#include "unicode/utypes.h" 28 /** 29 * \file 30 * \brief C API: Platform Utilities 31 */ 32 33/*==========================================================================*/ 34/* Platform utilities */ 35/*==========================================================================*/ 36 37/** 38 * Platform utilities isolates the platform dependencies of the 39 * libarary. For each platform which this code is ported to, these 40 * functions may have to be re-implemented. 41 */ 42 43/** 44 * Return the ICU data directory. 45 * The data directory is where common format ICU data files (.dat files) 46 * are loaded from. Note that normal use of the built-in ICU 47 * facilities does not require loading of an external data file; 48 * unless you are adding custom data to ICU, the data directory 49 * does not need to be set. 50 * 51 * The data directory is determined as follows: 52 * If u_setDataDirectory() has been called, that is it, otherwise 53 * if the ICU_DATA environment variable is set, use that, otherwise 54 * If a data directory was specifed at ICU build time 55 * <code> 56 * \code 57 * #define ICU_DATA_DIR "path" 58 * \endcode 59 * </code> use that, 60 * otherwise no data directory is available. 61 * 62 * @return the data directory, or an empty string ("") if no data directory has 63 * been specified. 64 * 65 * @stable ICU 2.0 66 */ 67U_STABLE const char* U_EXPORT2 u_getDataDirectory(void); 68 69/** 70 * Set the ICU data directory. 71 * The data directory is where common format ICU data files (.dat files) 72 * are loaded from. Note that normal use of the built-in ICU 73 * facilities does not require loading of an external data file; 74 * unless you are adding custom data to ICU, the data directory 75 * does not need to be set. 76 * 77 * This function should be called at most once in a process, before the 78 * first ICU operation (e.g., u_init()) that will require the loading of an 79 * ICU data file. 80 * This function is not thread-safe. Use it before calling ICU APIs from 81 * multiple threads. 82 * 83 * @param directory The directory to be set. 84 * 85 * @see u_init 86 * @stable ICU 2.0 87 */ 88U_STABLE void U_EXPORT2 u_setDataDirectory(const char *directory); 89 90/** 91 * @{ 92 * Filesystem file and path separator characters. 93 * Example: '/' and ':' on Unix, '\\' and ';' on Windows. 94 * @stable ICU 2.0 95 */ 96#if U_PLATFORM == U_PF_CLASSIC_MACOS 97# define U_FILE_SEP_CHAR ':' 98# define U_FILE_ALT_SEP_CHAR ':' 99# define U_PATH_SEP_CHAR ';' 100# define U_FILE_SEP_STRING ":" 101# define U_FILE_ALT_SEP_STRING ":" 102# define U_PATH_SEP_STRING ";" 103#elif U_PLATFORM_USES_ONLY_WIN32_API 104# define U_FILE_SEP_CHAR '\\' 105# define U_FILE_ALT_SEP_CHAR '/' 106# define U_PATH_SEP_CHAR ';' 107# define U_FILE_SEP_STRING "\\" 108# define U_FILE_ALT_SEP_STRING "/" 109# define U_PATH_SEP_STRING ";" 110#else 111# define U_FILE_SEP_CHAR '/' 112# define U_FILE_ALT_SEP_CHAR '/' 113# define U_PATH_SEP_CHAR ':' 114# define U_FILE_SEP_STRING "/" 115# define U_FILE_ALT_SEP_STRING "/" 116# define U_PATH_SEP_STRING ":" 117#endif 118 119/** @} */ 120 121/** 122 * Convert char characters to UChar characters. 123 * This utility function is useful only for "invariant characters" 124 * that are encoded in the platform default encoding. 125 * They are a small, constant subset of the encoding and include 126 * just the latin letters, digits, and some punctuation. 127 * For details, see U_CHARSET_FAMILY. 128 * 129 * @param cs Input string, points to <code>length</code> 130 * character bytes from a subset of the platform encoding. 131 * @param us Output string, points to memory for <code>length</code> 132 * Unicode characters. 133 * @param length The number of characters to convert; this may 134 * include the terminating <code>NUL</code>. 135 * 136 * @see U_CHARSET_FAMILY 137 * @stable ICU 2.0 138 */ 139U_STABLE void U_EXPORT2 140u_charsToUChars(const char *cs, UChar *us, int32_t length); 141 142/** 143 * Convert UChar characters to char characters. 144 * This utility function is useful only for "invariant characters" 145 * that can be encoded in the platform default encoding. 146 * They are a small, constant subset of the encoding and include 147 * just the latin letters, digits, and some punctuation. 148 * For details, see U_CHARSET_FAMILY. 149 * 150 * @param us Input string, points to <code>length</code> 151 * Unicode characters that can be encoded with the 152 * codepage-invariant subset of the platform encoding. 153 * @param cs Output string, points to memory for <code>length</code> 154 * character bytes. 155 * @param length The number of characters to convert; this may 156 * include the terminating <code>NUL</code>. 157 * 158 * @see U_CHARSET_FAMILY 159 * @stable ICU 2.0 160 */ 161U_STABLE void U_EXPORT2 162u_UCharsToChars(const UChar *us, char *cs, int32_t length); 163 164#endif 165