1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/common/unicode/putil.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,164 @@ 1.4 +/* 1.5 +****************************************************************************** 1.6 +* 1.7 +* Copyright (C) 1997-2011, International Business Machines 1.8 +* Corporation and others. All Rights Reserved. 1.9 +* 1.10 +****************************************************************************** 1.11 +* 1.12 +* FILE NAME : putil.h 1.13 +* 1.14 +* Date Name Description 1.15 +* 05/14/98 nos Creation (content moved here from utypes.h). 1.16 +* 06/17/99 erm Added IEEE_754 1.17 +* 07/22/98 stephen Added IEEEremainder, max, min, trunc 1.18 +* 08/13/98 stephen Added isNegativeInfinity, isPositiveInfinity 1.19 +* 08/24/98 stephen Added longBitsFromDouble 1.20 +* 03/02/99 stephen Removed openFile(). Added AS400 support. 1.21 +* 04/15/99 stephen Converted to C 1.22 +* 11/15/99 helena Integrated S/390 changes for IEEE support. 1.23 +* 01/11/00 helena Added u_getVersion. 1.24 +****************************************************************************** 1.25 +*/ 1.26 + 1.27 +#ifndef PUTIL_H 1.28 +#define PUTIL_H 1.29 + 1.30 +#include "unicode/utypes.h" 1.31 + /** 1.32 + * \file 1.33 + * \brief C API: Platform Utilities 1.34 + */ 1.35 + 1.36 +/*==========================================================================*/ 1.37 +/* Platform utilities */ 1.38 +/*==========================================================================*/ 1.39 + 1.40 +/** 1.41 + * Platform utilities isolates the platform dependencies of the 1.42 + * libarary. For each platform which this code is ported to, these 1.43 + * functions may have to be re-implemented. 1.44 + */ 1.45 + 1.46 +/** 1.47 + * Return the ICU data directory. 1.48 + * The data directory is where common format ICU data files (.dat files) 1.49 + * are loaded from. Note that normal use of the built-in ICU 1.50 + * facilities does not require loading of an external data file; 1.51 + * unless you are adding custom data to ICU, the data directory 1.52 + * does not need to be set. 1.53 + * 1.54 + * The data directory is determined as follows: 1.55 + * If u_setDataDirectory() has been called, that is it, otherwise 1.56 + * if the ICU_DATA environment variable is set, use that, otherwise 1.57 + * If a data directory was specifed at ICU build time 1.58 + * <code> 1.59 + * \code 1.60 + * #define ICU_DATA_DIR "path" 1.61 + * \endcode 1.62 + * </code> use that, 1.63 + * otherwise no data directory is available. 1.64 + * 1.65 + * @return the data directory, or an empty string ("") if no data directory has 1.66 + * been specified. 1.67 + * 1.68 + * @stable ICU 2.0 1.69 + */ 1.70 +U_STABLE const char* U_EXPORT2 u_getDataDirectory(void); 1.71 + 1.72 +/** 1.73 + * Set the ICU data directory. 1.74 + * The data directory is where common format ICU data files (.dat files) 1.75 + * are loaded from. Note that normal use of the built-in ICU 1.76 + * facilities does not require loading of an external data file; 1.77 + * unless you are adding custom data to ICU, the data directory 1.78 + * does not need to be set. 1.79 + * 1.80 + * This function should be called at most once in a process, before the 1.81 + * first ICU operation (e.g., u_init()) that will require the loading of an 1.82 + * ICU data file. 1.83 + * This function is not thread-safe. Use it before calling ICU APIs from 1.84 + * multiple threads. 1.85 + * 1.86 + * @param directory The directory to be set. 1.87 + * 1.88 + * @see u_init 1.89 + * @stable ICU 2.0 1.90 + */ 1.91 +U_STABLE void U_EXPORT2 u_setDataDirectory(const char *directory); 1.92 + 1.93 +/** 1.94 + * @{ 1.95 + * Filesystem file and path separator characters. 1.96 + * Example: '/' and ':' on Unix, '\\' and ';' on Windows. 1.97 + * @stable ICU 2.0 1.98 + */ 1.99 +#if U_PLATFORM == U_PF_CLASSIC_MACOS 1.100 +# define U_FILE_SEP_CHAR ':' 1.101 +# define U_FILE_ALT_SEP_CHAR ':' 1.102 +# define U_PATH_SEP_CHAR ';' 1.103 +# define U_FILE_SEP_STRING ":" 1.104 +# define U_FILE_ALT_SEP_STRING ":" 1.105 +# define U_PATH_SEP_STRING ";" 1.106 +#elif U_PLATFORM_USES_ONLY_WIN32_API 1.107 +# define U_FILE_SEP_CHAR '\\' 1.108 +# define U_FILE_ALT_SEP_CHAR '/' 1.109 +# define U_PATH_SEP_CHAR ';' 1.110 +# define U_FILE_SEP_STRING "\\" 1.111 +# define U_FILE_ALT_SEP_STRING "/" 1.112 +# define U_PATH_SEP_STRING ";" 1.113 +#else 1.114 +# define U_FILE_SEP_CHAR '/' 1.115 +# define U_FILE_ALT_SEP_CHAR '/' 1.116 +# define U_PATH_SEP_CHAR ':' 1.117 +# define U_FILE_SEP_STRING "/" 1.118 +# define U_FILE_ALT_SEP_STRING "/" 1.119 +# define U_PATH_SEP_STRING ":" 1.120 +#endif 1.121 + 1.122 +/** @} */ 1.123 + 1.124 +/** 1.125 + * Convert char characters to UChar characters. 1.126 + * This utility function is useful only for "invariant characters" 1.127 + * that are encoded in the platform default encoding. 1.128 + * They are a small, constant subset of the encoding and include 1.129 + * just the latin letters, digits, and some punctuation. 1.130 + * For details, see U_CHARSET_FAMILY. 1.131 + * 1.132 + * @param cs Input string, points to <code>length</code> 1.133 + * character bytes from a subset of the platform encoding. 1.134 + * @param us Output string, points to memory for <code>length</code> 1.135 + * Unicode characters. 1.136 + * @param length The number of characters to convert; this may 1.137 + * include the terminating <code>NUL</code>. 1.138 + * 1.139 + * @see U_CHARSET_FAMILY 1.140 + * @stable ICU 2.0 1.141 + */ 1.142 +U_STABLE void U_EXPORT2 1.143 +u_charsToUChars(const char *cs, UChar *us, int32_t length); 1.144 + 1.145 +/** 1.146 + * Convert UChar characters to char characters. 1.147 + * This utility function is useful only for "invariant characters" 1.148 + * that can be encoded in the platform default encoding. 1.149 + * They are a small, constant subset of the encoding and include 1.150 + * just the latin letters, digits, and some punctuation. 1.151 + * For details, see U_CHARSET_FAMILY. 1.152 + * 1.153 + * @param us Input string, points to <code>length</code> 1.154 + * Unicode characters that can be encoded with the 1.155 + * codepage-invariant subset of the platform encoding. 1.156 + * @param cs Output string, points to memory for <code>length</code> 1.157 + * character bytes. 1.158 + * @param length The number of characters to convert; this may 1.159 + * include the terminating <code>NUL</code>. 1.160 + * 1.161 + * @see U_CHARSET_FAMILY 1.162 + * @stable ICU 2.0 1.163 + */ 1.164 +U_STABLE void U_EXPORT2 1.165 +u_UCharsToChars(const UChar *us, char *cs, int32_t length); 1.166 + 1.167 +#endif