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