putil.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /*
  2. ******************************************************************************
  3. *
  4. * Copyright (C) 1997-2009, International Business Machines
  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. #ifndef PUTIL_H
  24. #define PUTIL_H
  25. #include "unicode/utypes.h"
  26. /**
  27. * \file
  28. * \brief C API: Platform Utilities
  29. */
  30. /** Define this to 1 if your platform supports IEEE 754 floating point,
  31. to 0 if it does not. */
  32. #ifndef IEEE_754
  33. # define IEEE_754 1
  34. #endif
  35. /*==========================================================================*/
  36. /* Platform utilities */
  37. /*==========================================================================*/
  38. /**
  39. * Platform utilities isolates the platform dependencies of the
  40. * libarary. For each platform which this code is ported to, these
  41. * functions may have to be re-implemented.
  42. */
  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
  55. * <code>
  56. * \code
  57. * #define ICU_DATA_DIR "path"
  58. * \endcode
  59. * </code> use that,
  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. */
  67. U_STABLE const char* U_EXPORT2 u_getDataDirectory(void);
  68. /**
  69. * Set the ICU data directory.
  70. * The data directory is where common format ICU data files (.dat files)
  71. * are loaded from. Note that normal use of the built-in ICU
  72. * facilities does not require loading of an external data file;
  73. * unless you are adding custom data to ICU, the data directory
  74. * does not need to be set.
  75. *
  76. * This function should be called at most once in a process, before the
  77. * first ICU operation (e.g., u_init()) that will require the loading of an
  78. * ICU data file.
  79. * This function is not thread-safe. Use it before calling ICU APIs from
  80. * multiple threads.
  81. *
  82. * @param directory The directory to be set.
  83. *
  84. * @see u_init
  85. * @stable ICU 2.0
  86. */
  87. U_STABLE void U_EXPORT2 u_setDataDirectory(const char *directory);
  88. #if !U_CHARSET_IS_UTF8
  89. /**
  90. * Please use ucnv_getDefaultName() instead.
  91. * Return the default codepage for this platform and locale.
  92. * This function can call setlocale() on Unix platforms. Please read the
  93. * platform documentation on setlocale() before calling this function.
  94. * @return the default codepage for this platform
  95. * @internal
  96. */
  97. U_INTERNAL const char* U_EXPORT2 uprv_getDefaultCodepage(void);
  98. #endif
  99. /**
  100. * Please use uloc_getDefault() instead.
  101. * Return the default locale ID string by querying ths system, or
  102. * zero if one cannot be found.
  103. * This function can call setlocale() on Unix platforms. Please read the
  104. * platform documentation on setlocale() before calling this function.
  105. * @return the default locale ID string
  106. * @internal
  107. */
  108. U_INTERNAL const char* U_EXPORT2 uprv_getDefaultLocaleID(void);
  109. /**
  110. * @{
  111. * Filesystem file and path separator characters.
  112. * Example: '/' and ':' on Unix, '\\' and ';' on Windows.
  113. * @stable ICU 2.0
  114. */
  115. #ifdef XP_MAC
  116. # define U_FILE_SEP_CHAR ':'
  117. # define U_FILE_ALT_SEP_CHAR ':'
  118. # define U_PATH_SEP_CHAR ';'
  119. # define U_FILE_SEP_STRING ":"
  120. # define U_FILE_ALT_SEP_STRING ":"
  121. # define U_PATH_SEP_STRING ";"
  122. #elif defined(WIN32) || defined(OS2)
  123. # define U_FILE_SEP_CHAR '\\'
  124. # define U_FILE_ALT_SEP_CHAR '/'
  125. # define U_PATH_SEP_CHAR ';'
  126. # define U_FILE_SEP_STRING "\\"
  127. # define U_FILE_ALT_SEP_STRING "/"
  128. # define U_PATH_SEP_STRING ";"
  129. #else
  130. # define U_FILE_SEP_CHAR '/'
  131. # define U_FILE_ALT_SEP_CHAR '/'
  132. # define U_PATH_SEP_CHAR ':'
  133. # define U_FILE_SEP_STRING "/"
  134. # define U_FILE_ALT_SEP_STRING "/"
  135. # define U_PATH_SEP_STRING ":"
  136. #endif
  137. /** @} */
  138. /**
  139. * Convert char characters to UChar characters.
  140. * This utility function is useful only for "invariant characters"
  141. * that are encoded in the platform default encoding.
  142. * They are a small, constant subset of the encoding and include
  143. * just the latin letters, digits, and some punctuation.
  144. * For details, see U_CHARSET_FAMILY.
  145. *
  146. * @param cs Input string, points to <code>length</code>
  147. * character bytes from a subset of the platform encoding.
  148. * @param us Output string, points to memory for <code>length</code>
  149. * Unicode characters.
  150. * @param length The number of characters to convert; this may
  151. * include the terminating <code>NUL</code>.
  152. *
  153. * @see U_CHARSET_FAMILY
  154. * @stable ICU 2.0
  155. */
  156. U_STABLE void U_EXPORT2
  157. u_charsToUChars(const char *cs, UChar *us, int32_t length);
  158. /**
  159. * Convert UChar characters to char characters.
  160. * This utility function is useful only for "invariant characters"
  161. * that can be encoded in the platform default encoding.
  162. * They are a small, constant subset of the encoding and include
  163. * just the latin letters, digits, and some punctuation.
  164. * For details, see U_CHARSET_FAMILY.
  165. *
  166. * @param us Input string, points to <code>length</code>
  167. * Unicode characters that can be encoded with the
  168. * codepage-invariant subset of the platform encoding.
  169. * @param cs Output string, points to memory for <code>length</code>
  170. * character bytes.
  171. * @param length The number of characters to convert; this may
  172. * include the terminating <code>NUL</code>.
  173. *
  174. * @see U_CHARSET_FAMILY
  175. * @stable ICU 2.0
  176. */
  177. U_STABLE void U_EXPORT2
  178. u_UCharsToChars(const UChar *us, char *cs, int32_t length);
  179. #endif