1999-12-28 23:39:02 +00:00
|
|
|
/*
|
2001-03-21 20:44:20 +00:00
|
|
|
******************************************************************************
|
1999-12-28 23:39:02 +00:00
|
|
|
*
|
2008-05-21 21:34:54 +00:00
|
|
|
* Copyright (C) 1997-2008, International Business Machines
|
1999-12-28 23:39:02 +00:00
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
*
|
2001-03-21 20:44:20 +00:00
|
|
|
******************************************************************************
|
1999-12-28 23:39:02 +00:00
|
|
|
*
|
|
|
|
* FILE NAME : putil.h
|
|
|
|
*
|
|
|
|
* Date Name Description
|
|
|
|
* 05/14/98 nos Creation (content moved here from utypes.h).
|
|
|
|
* 06/17/99 erm Added IEEE_754
|
|
|
|
* 07/22/98 stephen Added IEEEremainder, max, min, trunc
|
|
|
|
* 08/13/98 stephen Added isNegativeInfinity, isPositiveInfinity
|
|
|
|
* 08/24/98 stephen Added longBitsFromDouble
|
|
|
|
* 03/02/99 stephen Removed openFile(). Added AS400 support.
|
|
|
|
* 04/15/99 stephen Converted to C
|
|
|
|
* 11/15/99 helena Integrated S/390 changes for IEEE support.
|
2000-01-11 23:20:26 +00:00
|
|
|
* 01/11/00 helena Added u_getVersion.
|
2001-03-21 20:44:20 +00:00
|
|
|
******************************************************************************
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PUTIL_H
|
|
|
|
#define PUTIL_H
|
|
|
|
|
|
|
|
#include "unicode/utypes.h"
|
2005-06-22 22:39:36 +00:00
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
* \brief C API: Platform Utilities
|
|
|
|
*/
|
|
|
|
|
2000-04-06 16:45:03 +00:00
|
|
|
/* Define this to 1 if your platform supports IEEE 754 floating point,
|
|
|
|
to 0 if it does not. */
|
|
|
|
#ifndef IEEE_754
|
|
|
|
# define IEEE_754 1
|
|
|
|
#endif
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2001-03-21 20:44:20 +00:00
|
|
|
/*==========================================================================*/
|
|
|
|
/* Platform utilities */
|
|
|
|
/*==========================================================================*/
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Platform utilities isolates the platform dependencies of the
|
|
|
|
* libarary. For each platform which this code is ported to, these
|
2001-10-11 21:41:11 +00:00
|
|
|
* functions may have to be re-implemented.
|
|
|
|
*/
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2000-03-22 18:31:40 +00:00
|
|
|
/**
|
2001-08-17 21:34:07 +00:00
|
|
|
* Return the ICU data directory.
|
|
|
|
* The data directory is where common format ICU data files (.dat files)
|
|
|
|
* are loaded from. Note that normal use of the built-in ICU
|
|
|
|
* facilities does not require loading of an external data file;
|
|
|
|
* unless you are adding custom data to ICU, the data directory
|
|
|
|
* does not need to be set.
|
|
|
|
*
|
|
|
|
* The data directory is determined as follows:
|
|
|
|
* If u_setDataDirectory() has been called, that is it, otherwise
|
|
|
|
* if the ICU_DATA environment variable is set, use that, otherwise
|
2003-05-29 23:13:24 +00:00
|
|
|
* If a data directory was specifed at ICU build time
|
2008-05-21 21:34:54 +00:00
|
|
|
* <code>( #define ICU_DATA_DIR "path" )</code>, use that,
|
2001-08-17 21:34:07 +00:00
|
|
|
* otherwise no data directory is available.
|
|
|
|
*
|
2001-11-09 18:17:40 +00:00
|
|
|
* @return the data directory, or an empty string ("") if no data directory has
|
2001-08-17 21:34:07 +00:00
|
|
|
* been specified.
|
|
|
|
*
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-03-22 18:31:40 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE const char* U_EXPORT2 u_getDataDirectory(void);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2000-03-22 18:31:40 +00:00
|
|
|
/**
|
2001-08-17 21:34:07 +00:00
|
|
|
* Set the ICU data directory.
|
|
|
|
* The data directory is where common format ICU data files (.dat files)
|
|
|
|
* are loaded from. Note that normal use of the built-in ICU
|
|
|
|
* facilities does not require loading of an external data file;
|
|
|
|
* unless you are adding custom data to ICU, the data directory
|
|
|
|
* does not need to be set.
|
|
|
|
*
|
|
|
|
* This function should be called at most once in a process, before the
|
2003-05-29 23:13:24 +00:00
|
|
|
* first ICU operation (e.g., u_init()) that will require the loading of an
|
|
|
|
* ICU data file.
|
|
|
|
* This function is not thread-safe. Use it before calling ICU APIs from
|
|
|
|
* multiple threads.
|
|
|
|
*
|
|
|
|
* @param directory The directory to be set.
|
|
|
|
*
|
|
|
|
* @see u_init
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-03-22 18:31:40 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE void U_EXPORT2 u_setDataDirectory(const char *directory);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2000-03-22 18:31:40 +00:00
|
|
|
/**
|
2002-12-10 23:15:21 +00:00
|
|
|
* Please use ucnv_getDefaultName() instead.
|
2002-10-24 20:52:54 +00:00
|
|
|
* Return the default codepage for this platform and locale.
|
|
|
|
* This function can call setlocale() on Unix platforms. Please read the
|
|
|
|
* platform documentation on setlocale() before calling this function.
|
2002-07-03 12:05:56 +00:00
|
|
|
* @return the default codepage for this platform
|
2002-12-10 23:15:21 +00:00
|
|
|
* @internal
|
2000-03-22 18:31:40 +00:00
|
|
|
*/
|
2004-06-12 00:56:53 +00:00
|
|
|
U_INTERNAL const char* U_EXPORT2 uprv_getDefaultCodepage(void);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2000-03-22 18:31:40 +00:00
|
|
|
/**
|
2002-12-10 23:15:21 +00:00
|
|
|
* Please use uloc_getDefault() instead.
|
2000-03-22 18:31:40 +00:00
|
|
|
* Return the default locale ID string by querying ths system, or
|
|
|
|
* zero if one cannot be found.
|
2002-10-24 20:52:54 +00:00
|
|
|
* This function can call setlocale() on Unix platforms. Please read the
|
|
|
|
* platform documentation on setlocale() before calling this function.
|
2002-07-03 12:05:56 +00:00
|
|
|
* @return the default locale ID string
|
2002-12-10 23:15:21 +00:00
|
|
|
* @internal
|
2000-03-22 18:31:40 +00:00
|
|
|
*/
|
2004-06-12 00:56:53 +00:00
|
|
|
U_INTERNAL const char* U_EXPORT2 uprv_getDefaultLocaleID(void);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Filesystem file and path separator characters.
|
|
|
|
* Example: '/' and ':' on Unix, '\\' and ';' on Windows.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
#ifdef XP_MAC
|
|
|
|
# define U_FILE_SEP_CHAR ':'
|
2003-09-12 21:06:27 +00:00
|
|
|
# define U_FILE_ALT_SEP_CHAR ':'
|
1999-12-28 23:39:02 +00:00
|
|
|
# define U_PATH_SEP_CHAR ';'
|
|
|
|
# define U_FILE_SEP_STRING ":"
|
2003-09-12 21:06:27 +00:00
|
|
|
# define U_FILE_ALT_SEP_STRING ":"
|
1999-12-28 23:39:02 +00:00
|
|
|
# define U_PATH_SEP_STRING ";"
|
2005-02-17 00:19:44 +00:00
|
|
|
#elif defined(U_WINDOWS)
|
1999-12-28 23:39:02 +00:00
|
|
|
# define U_FILE_SEP_CHAR '\\'
|
2003-09-12 21:06:27 +00:00
|
|
|
# define U_FILE_ALT_SEP_CHAR '/'
|
1999-12-28 23:39:02 +00:00
|
|
|
# define U_PATH_SEP_CHAR ';'
|
|
|
|
# define U_FILE_SEP_STRING "\\"
|
2003-09-12 21:06:27 +00:00
|
|
|
# define U_FILE_ALT_SEP_STRING "/"
|
1999-12-28 23:39:02 +00:00
|
|
|
# define U_PATH_SEP_STRING ";"
|
|
|
|
#else
|
|
|
|
# define U_FILE_SEP_CHAR '/'
|
2003-09-12 21:06:27 +00:00
|
|
|
# define U_FILE_ALT_SEP_CHAR '/'
|
1999-12-28 23:39:02 +00:00
|
|
|
# define U_PATH_SEP_CHAR ':'
|
|
|
|
# define U_FILE_SEP_STRING "/"
|
2003-09-12 21:06:27 +00:00
|
|
|
# define U_FILE_ALT_SEP_STRING "/"
|
1999-12-28 23:39:02 +00:00
|
|
|
# define U_PATH_SEP_STRING ":"
|
|
|
|
#endif
|
|
|
|
|
2004-10-18 03:03:13 +00:00
|
|
|
/**
|
|
|
|
* Convert char characters to UChar characters.
|
|
|
|
* This utility function is useful only for "invariant characters"
|
|
|
|
* that are encoded in the platform default encoding.
|
|
|
|
* They are a small, constant subset of the encoding and include
|
|
|
|
* just the latin letters, digits, and some punctuation.
|
|
|
|
* For details, see U_CHARSET_FAMILY.
|
|
|
|
*
|
|
|
|
* @param cs Input string, points to <code>length</code>
|
|
|
|
* character bytes from a subset of the platform encoding.
|
|
|
|
* @param us Output string, points to memory for <code>length</code>
|
|
|
|
* Unicode characters.
|
|
|
|
* @param length The number of characters to convert; this may
|
|
|
|
* include the terminating <code>NUL</code>.
|
|
|
|
*
|
|
|
|
* @see U_CHARSET_FAMILY
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
|
|
|
U_STABLE void U_EXPORT2
|
|
|
|
u_charsToUChars(const char *cs, UChar *us, int32_t length);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert UChar characters to char characters.
|
|
|
|
* This utility function is useful only for "invariant characters"
|
|
|
|
* that can be encoded in the platform default encoding.
|
|
|
|
* They are a small, constant subset of the encoding and include
|
|
|
|
* just the latin letters, digits, and some punctuation.
|
|
|
|
* For details, see U_CHARSET_FAMILY.
|
|
|
|
*
|
|
|
|
* @param us Input string, points to <code>length</code>
|
|
|
|
* Unicode characters that can be encoded with the
|
|
|
|
* codepage-invariant subset of the platform encoding.
|
|
|
|
* @param cs Output string, points to memory for <code>length</code>
|
|
|
|
* character bytes.
|
|
|
|
* @param length The number of characters to convert; this may
|
|
|
|
* include the terminating <code>NUL</code>.
|
|
|
|
*
|
|
|
|
* @see U_CHARSET_FAMILY
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
|
|
|
U_STABLE void U_EXPORT2
|
|
|
|
u_UCharsToChars(const UChar *us, char *cs, int32_t length);
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
#endif
|