putil.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. ******************************************************************************
  3. *
  4. * Copyright (C) 1997-2014, 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. /*==========================================================================*/
  31. /* Platform utilities */
  32. /*==========================================================================*/
  33. /**
  34. * Platform utilities isolates the platform dependencies of the
  35. * libarary. For each platform which this code is ported to, these
  36. * functions may have to be re-implemented.
  37. */
  38. /**
  39. * Return the ICU data directory.
  40. * The data directory is where common format ICU data files (.dat files)
  41. * are loaded from. Note that normal use of the built-in ICU
  42. * facilities does not require loading of an external data file;
  43. * unless you are adding custom data to ICU, the data directory
  44. * does not need to be set.
  45. *
  46. * The data directory is determined as follows:
  47. * If u_setDataDirectory() has been called, that is it, otherwise
  48. * if the ICU_DATA environment variable is set, use that, otherwise
  49. * If a data directory was specifed at ICU build time
  50. * <code>
  51. * \code
  52. * #define ICU_DATA_DIR "path"
  53. * \endcode
  54. * </code> use that,
  55. * otherwise no data directory is available.
  56. *
  57. * @return the data directory, or an empty string ("") if no data directory has
  58. * been specified.
  59. *
  60. * @stable ICU 2.0
  61. */
  62. U_STABLE const char* U_EXPORT2 u_getDataDirectory(void);
  63. /**
  64. * Set the ICU data directory.
  65. * The data directory is where common format ICU data files (.dat files)
  66. * are loaded from. Note that normal use of the built-in ICU
  67. * facilities does not require loading of an external data file;
  68. * unless you are adding custom data to ICU, the data directory
  69. * does not need to be set.
  70. *
  71. * This function should be called at most once in a process, before the
  72. * first ICU operation (e.g., u_init()) that will require the loading of an
  73. * ICU data file.
  74. * This function is not thread-safe. Use it before calling ICU APIs from
  75. * multiple threads.
  76. *
  77. * @param directory The directory to be set.
  78. *
  79. * @see u_init
  80. * @stable ICU 2.0
  81. */
  82. U_STABLE void U_EXPORT2 u_setDataDirectory(const char *directory);
  83. #ifndef U_HIDE_INTERNAL_API
  84. /**
  85. * Return the time zone files override directory, or an empty string if
  86. * no directory was specified. Certain time zone resources will be preferrentially
  87. * loaded from individual files in this directory.
  88. *
  89. * @return the time zone data override directory.
  90. * @internal
  91. */
  92. U_INTERNAL const char * U_EXPORT2 u_getTimeZoneFilesDirectory(UErrorCode *status);
  93. /**
  94. * Set the time zone files override directory.
  95. * This function is not thread safe; it must not be called concurrently with
  96. * u_getTimeZoneFilesDirectory() or any other use of ICU time zone functions.
  97. * This function should only be called before using any ICU service that
  98. * will access the time zone data.
  99. * @internal
  100. */
  101. U_INTERNAL void U_EXPORT2 u_setTimeZoneFilesDirectory(const char *path, UErrorCode *status);
  102. #endif /* U_HIDE_INTERNAL_API */
  103. /**
  104. * @{
  105. * Filesystem file and path separator characters.
  106. * Example: '/' and ':' on Unix, '\\' and ';' on Windows.
  107. * @stable ICU 2.0
  108. */
  109. #if U_PLATFORM_USES_ONLY_WIN32_API
  110. # define U_FILE_SEP_CHAR '\\'
  111. # define U_FILE_ALT_SEP_CHAR '/'
  112. # define U_PATH_SEP_CHAR ';'
  113. # define U_FILE_SEP_STRING "\\"
  114. # define U_FILE_ALT_SEP_STRING "/"
  115. # define U_PATH_SEP_STRING ";"
  116. #else
  117. # define U_FILE_SEP_CHAR '/'
  118. # define U_FILE_ALT_SEP_CHAR '/'
  119. # define U_PATH_SEP_CHAR ':'
  120. # define U_FILE_SEP_STRING "/"
  121. # define U_FILE_ALT_SEP_STRING "/"
  122. # define U_PATH_SEP_STRING ":"
  123. #endif
  124. /** @} */
  125. /**
  126. * Convert char characters to UChar characters.
  127. * This utility function is useful only for "invariant characters"
  128. * that are encoded in the platform default encoding.
  129. * They are a small, constant subset of the encoding and include
  130. * just the latin letters, digits, and some punctuation.
  131. * For details, see U_CHARSET_FAMILY.
  132. *
  133. * @param cs Input string, points to <code>length</code>
  134. * character bytes from a subset of the platform encoding.
  135. * @param us Output string, points to memory for <code>length</code>
  136. * Unicode characters.
  137. * @param length The number of characters to convert; this may
  138. * include the terminating <code>NUL</code>.
  139. *
  140. * @see U_CHARSET_FAMILY
  141. * @stable ICU 2.0
  142. */
  143. U_STABLE void U_EXPORT2
  144. u_charsToUChars(const char *cs, UChar *us, int32_t length);
  145. /**
  146. * Convert UChar characters to char characters.
  147. * This utility function is useful only for "invariant characters"
  148. * that can be encoded in the platform default encoding.
  149. * They are a small, constant subset of the encoding and include
  150. * just the latin letters, digits, and some punctuation.
  151. * For details, see U_CHARSET_FAMILY.
  152. *
  153. * @param us Input string, points to <code>length</code>
  154. * Unicode characters that can be encoded with the
  155. * codepage-invariant subset of the platform encoding.
  156. * @param cs Output string, points to memory for <code>length</code>
  157. * character bytes.
  158. * @param length The number of characters to convert; this may
  159. * include the terminating <code>NUL</code>.
  160. *
  161. * @see U_CHARSET_FAMILY
  162. * @stable ICU 2.0
  163. */
  164. U_STABLE void U_EXPORT2
  165. u_UCharsToChars(const UChar *us, char *cs, int32_t length);
  166. #endif