OLD | NEW |
(Empty) | |
| 1 /* |
| 2 ****************************************************************************** |
| 3 * |
| 4 * Copyright (C) 1997-2009, 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 /** Define this to 1 if your platform supports IEEE 754 floating point, |
| 34 to 0 if it does not. */ |
| 35 #ifndef IEEE_754 |
| 36 # define IEEE_754 1 |
| 37 #endif |
| 38 |
| 39 /*==========================================================================*/ |
| 40 /* Platform utilities */ |
| 41 /*==========================================================================*/ |
| 42 |
| 43 /** |
| 44 * Platform utilities isolates the platform dependencies of the |
| 45 * libarary. For each platform which this code is ported to, these |
| 46 * functions may have to be re-implemented. |
| 47 */ |
| 48 |
| 49 /** |
| 50 * Return the ICU data directory. |
| 51 * The data directory is where common format ICU data files (.dat files) |
| 52 * are loaded from. Note that normal use of the built-in ICU |
| 53 * facilities does not require loading of an external data file; |
| 54 * unless you are adding custom data to ICU, the data directory |
| 55 * does not need to be set. |
| 56 * |
| 57 * The data directory is determined as follows: |
| 58 * If u_setDataDirectory() has been called, that is it, otherwise |
| 59 * if the ICU_DATA environment variable is set, use that, otherwise |
| 60 * If a data directory was specifed at ICU build time |
| 61 * <code> |
| 62 * \code |
| 63 * #define ICU_DATA_DIR "path" |
| 64 * \endcode |
| 65 * </code> use that, |
| 66 * otherwise no data directory is available. |
| 67 * |
| 68 * @return the data directory, or an empty string ("") if no data directory has |
| 69 * been specified. |
| 70 * |
| 71 * @stable ICU 2.0 |
| 72 */ |
| 73 U_STABLE const char* U_EXPORT2 u_getDataDirectory(void); |
| 74 |
| 75 /** |
| 76 * Set the ICU data directory. |
| 77 * The data directory is where common format ICU data files (.dat files) |
| 78 * are loaded from. Note that normal use of the built-in ICU |
| 79 * facilities does not require loading of an external data file; |
| 80 * unless you are adding custom data to ICU, the data directory |
| 81 * does not need to be set. |
| 82 * |
| 83 * This function should be called at most once in a process, before the |
| 84 * first ICU operation (e.g., u_init()) that will require the loading of an |
| 85 * ICU data file. |
| 86 * This function is not thread-safe. Use it before calling ICU APIs from |
| 87 * multiple threads. |
| 88 * |
| 89 * @param directory The directory to be set. |
| 90 * |
| 91 * @see u_init |
| 92 * @stable ICU 2.0 |
| 93 */ |
| 94 U_STABLE void U_EXPORT2 u_setDataDirectory(const char *directory); |
| 95 |
| 96 #if !U_CHARSET_IS_UTF8 |
| 97 /** |
| 98 * Please use ucnv_getDefaultName() instead. |
| 99 * Return the default codepage for this platform and locale. |
| 100 * This function can call setlocale() on Unix platforms. Please read the |
| 101 * platform documentation on setlocale() before calling this function. |
| 102 * @return the default codepage for this platform |
| 103 * @internal |
| 104 */ |
| 105 U_INTERNAL const char* U_EXPORT2 uprv_getDefaultCodepage(void); |
| 106 #endif |
| 107 |
| 108 /** |
| 109 * Please use uloc_getDefault() instead. |
| 110 * Return the default locale ID string by querying ths system, or |
| 111 * zero if one cannot be found. |
| 112 * This function can call setlocale() on Unix platforms. Please read the |
| 113 * platform documentation on setlocale() before calling this function. |
| 114 * @return the default locale ID string |
| 115 * @internal |
| 116 */ |
| 117 U_INTERNAL const char* U_EXPORT2 uprv_getDefaultLocaleID(void); |
| 118 |
| 119 /** |
| 120 * @{ |
| 121 * Filesystem file and path separator characters. |
| 122 * Example: '/' and ':' on Unix, '\\' and ';' on Windows. |
| 123 * @stable ICU 2.0 |
| 124 */ |
| 125 #ifdef XP_MAC |
| 126 # define U_FILE_SEP_CHAR ':' |
| 127 # define U_FILE_ALT_SEP_CHAR ':' |
| 128 # define U_PATH_SEP_CHAR ';' |
| 129 # define U_FILE_SEP_STRING ":" |
| 130 # define U_FILE_ALT_SEP_STRING ":" |
| 131 # define U_PATH_SEP_STRING ";" |
| 132 #elif defined(U_WINDOWS) |
| 133 # define U_FILE_SEP_CHAR '\\' |
| 134 # define U_FILE_ALT_SEP_CHAR '/' |
| 135 # define U_PATH_SEP_CHAR ';' |
| 136 # define U_FILE_SEP_STRING "\\" |
| 137 # define U_FILE_ALT_SEP_STRING "/" |
| 138 # define U_PATH_SEP_STRING ";" |
| 139 #else |
| 140 # define U_FILE_SEP_CHAR '/' |
| 141 # define U_FILE_ALT_SEP_CHAR '/' |
| 142 # define U_PATH_SEP_CHAR ':' |
| 143 # define U_FILE_SEP_STRING "/" |
| 144 # define U_FILE_ALT_SEP_STRING "/" |
| 145 # define U_PATH_SEP_STRING ":" |
| 146 #endif |
| 147 |
| 148 /** @} */ |
| 149 |
| 150 /** |
| 151 * Convert char characters to UChar characters. |
| 152 * This utility function is useful only for "invariant characters" |
| 153 * that are encoded in the platform default encoding. |
| 154 * They are a small, constant subset of the encoding and include |
| 155 * just the latin letters, digits, and some punctuation. |
| 156 * For details, see U_CHARSET_FAMILY. |
| 157 * |
| 158 * @param cs Input string, points to <code>length</code> |
| 159 * character bytes from a subset of the platform encoding. |
| 160 * @param us Output string, points to memory for <code>length</code> |
| 161 * Unicode characters. |
| 162 * @param length The number of characters to convert; this may |
| 163 * include the terminating <code>NUL</code>. |
| 164 * |
| 165 * @see U_CHARSET_FAMILY |
| 166 * @stable ICU 2.0 |
| 167 */ |
| 168 U_STABLE void U_EXPORT2 |
| 169 u_charsToUChars(const char *cs, UChar *us, int32_t length); |
| 170 |
| 171 /** |
| 172 * Convert UChar characters to char characters. |
| 173 * This utility function is useful only for "invariant characters" |
| 174 * that can be encoded in the platform default encoding. |
| 175 * They are a small, constant subset of the encoding and include |
| 176 * just the latin letters, digits, and some punctuation. |
| 177 * For details, see U_CHARSET_FAMILY. |
| 178 * |
| 179 * @param us Input string, points to <code>length</code> |
| 180 * Unicode characters that can be encoded with the |
| 181 * codepage-invariant subset of the platform encoding. |
| 182 * @param cs Output string, points to memory for <code>length</code> |
| 183 * character bytes. |
| 184 * @param length The number of characters to convert; this may |
| 185 * include the terminating <code>NUL</code>. |
| 186 * |
| 187 * @see U_CHARSET_FAMILY |
| 188 * @stable ICU 2.0 |
| 189 */ |
| 190 U_STABLE void U_EXPORT2 |
| 191 u_UCharsToChars(const UChar *us, char *cs, int32_t length); |
| 192 |
| 193 #endif |
OLD | NEW |