]> git.saurik.com Git - apple/icu.git/blame - icuSources/common/unicode/putil.h
ICU-531.30.tar.gz
[apple/icu.git] / icuSources / common / unicode / putil.h
CommitLineData
b75a7d8f
A
1/*
2******************************************************************************
3*
4388f060 4* Copyright (C) 1997-2011, International Business Machines
b75a7d8f
A
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"
73c04bcf
A
28 /**
29 * \file
30 * \brief C API: Platform Utilities
31 */
729e4ab9 32
b75a7d8f
A
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
b75a7d8f
A
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
729e4ab9
A
55 * <code>
56 * \code
57 * #define ICU_DATA_DIR "path"
58 * \endcode
59 * </code> use that,
b75a7d8f
A
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 */
374ca955 67U_STABLE const char* U_EXPORT2 u_getDataDirectory(void);
b75a7d8f
A
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 */
374ca955 88U_STABLE void U_EXPORT2 u_setDataDirectory(const char *directory);
b75a7d8f 89
b75a7d8f 90/**
729e4ab9 91 * @{
b75a7d8f
A
92 * Filesystem file and path separator characters.
93 * Example: '/' and ':' on Unix, '\\' and ';' on Windows.
94 * @stable ICU 2.0
95 */
4388f060 96#if U_PLATFORM == U_PF_CLASSIC_MACOS
b75a7d8f 97# define U_FILE_SEP_CHAR ':'
374ca955 98# define U_FILE_ALT_SEP_CHAR ':'
b75a7d8f
A
99# define U_PATH_SEP_CHAR ';'
100# define U_FILE_SEP_STRING ":"
374ca955 101# define U_FILE_ALT_SEP_STRING ":"
b75a7d8f 102# define U_PATH_SEP_STRING ";"
4388f060 103#elif U_PLATFORM_USES_ONLY_WIN32_API
b75a7d8f 104# define U_FILE_SEP_CHAR '\\'
374ca955 105# define U_FILE_ALT_SEP_CHAR '/'
b75a7d8f
A
106# define U_PATH_SEP_CHAR ';'
107# define U_FILE_SEP_STRING "\\"
374ca955 108# define U_FILE_ALT_SEP_STRING "/"
b75a7d8f
A
109# define U_PATH_SEP_STRING ";"
110#else
111# define U_FILE_SEP_CHAR '/'
374ca955 112# define U_FILE_ALT_SEP_CHAR '/'
b75a7d8f
A
113# define U_PATH_SEP_CHAR ':'
114# define U_FILE_SEP_STRING "/"
374ca955 115# define U_FILE_ALT_SEP_STRING "/"
b75a7d8f
A
116# define U_PATH_SEP_STRING ":"
117#endif
118
729e4ab9
A
119/** @} */
120
b75a7d8f
A
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.
374ca955 127 * For details, see U_CHARSET_FAMILY.
b75a7d8f
A
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>.
374ca955
A
135 *
136 * @see U_CHARSET_FAMILY
b75a7d8f
A
137 * @stable ICU 2.0
138 */
374ca955 139U_STABLE void U_EXPORT2
b75a7d8f
A
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.
374ca955 148 * For details, see U_CHARSET_FAMILY.
b75a7d8f
A
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>.
374ca955
A
157 *
158 * @see U_CHARSET_FAMILY
b75a7d8f
A
159 * @stable ICU 2.0
160 */
374ca955 161U_STABLE void U_EXPORT2
b75a7d8f
A
162u_UCharsToChars(const UChar *us, char *cs, int32_t length);
163
b75a7d8f 164#endif