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