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