putil.h 6.3 KB

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