ICU 70.1 70.1

Functions
putil.h File Reference

C API: Platform Utilities. More...

`#include "unicode/utypes.h"`

Go to the source code of this file.

## Macros
#define | U_FILE_SEP_CHAR '/'
| Filesystem file and path separator characters. More...
#define | U_FILE_ALT_SEP_CHAR '/'
| Filesystem file and path separator characters. More...
#define | U_PATH_SEP_CHAR ':'
| Filesystem file and path separator characters. More...
#define | U_FILE_SEP_STRING "/"
| Filesystem file and path separator characters. More...
#define | U_FILE_ALT_SEP_STRING "/"
| Filesystem file and path separator characters. More...
#define | U_PATH_SEP_STRING ":"
| Filesystem file and path separator characters. More...

## Functions
U_CAPI const char * | u_getDataDirectory (void)
| Platform utilities isolates the platform dependencies of the library. More...
U_CAPI void | u_setDataDirectory (const char *directory)
| Set the ICU data directory. More...
U_CAPI const char * | u_getTimeZoneFilesDirectory (UErrorCode *status)
| Return the time zone files override directory, or an empty string if no directory was specified. More...
U_CAPI void | u_setTimeZoneFilesDirectory (const char *path, UErrorCode *status)
| Set the time zone files override directory. More...
U_CAPI void | u_charsToUChars (const char *cs, UChar *us, int32_t length)
| Convert char characters to UChar characters. More...
U_CAPI void | u_UCharsToChars (const UChar *us, char *cs, int32_t length)
| Convert UChar characters to char characters. More...

## Detailed Description

C API: Platform Utilities.

Definition in file putil.h.

## Macro Definition Documentation

## ◆ U_FILE_ALT_SEP_CHAR

#define U_FILE_ALT_SEP_CHAR '/'

Filesystem file and path separator characters.

Example: '/' and ':' on Unix, '\' and ';' on Windows.

Stable:
  ICU 2.0

Definition at line 131 of file putil.h.

## ◆ U_FILE_ALT_SEP_STRING

#define U_FILE_ALT_SEP_STRING "/"

Filesystem file and path separator characters.

Example: '/' and ':' on Unix, '\' and ';' on Windows.

Stable:
  ICU 2.0

Definition at line 134 of file putil.h.

## ◆ U_FILE_SEP_CHAR

#define U_FILE_SEP_CHAR '/'

Filesystem file and path separator characters.

Example: '/' and ':' on Unix, '\' and ';' on Windows.

Stable:
  ICU 2.0

Definition at line 130 of file putil.h.

## ◆ U_FILE_SEP_STRING

#define U_FILE_SEP_STRING "/"

Filesystem file and path separator characters.

Example: '/' and ':' on Unix, '\' and ';' on Windows.

Stable:
  ICU 2.0

Definition at line 133 of file putil.h.

## ◆ U_PATH_SEP_CHAR

#define U_PATH_SEP_CHAR ':'

Filesystem file and path separator characters.

Example: '/' and ':' on Unix, '\' and ';' on Windows.

Stable:
  ICU 2.0

Definition at line 132 of file putil.h.

## ◆ U_PATH_SEP_STRING

#define U_PATH_SEP_STRING ":"

Filesystem file and path separator characters.

Example: '/' and ':' on Unix, '\' and ';' on Windows.

Stable:
  ICU 2.0

Definition at line 135 of file putil.h.

## Function Documentation

## ◆ u_charsToUChars()

U_CAPI void u_charsToUChars | ( | const char * | cs,
|  | UChar * | us,
|  | int32_t | length
| ) |  |

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.

Parameters

  cs | Input string, points to `length` character bytes from a subset of the platform encoding.
  us | Output string, points to memory for `length` Unicode characters.
  length | The number of characters to convert; this may include the terminating `NUL`.

See also
  U_CHARSET_FAMILY

Stable:
  ICU 2.0

## ◆ u_getDataDirectory()

U_CAPI const char * u_getDataDirectory | ( | void |  | ) |

Platform utilities isolates the platform dependencies of the library.

For each platform which this code is ported to, these functions may have to be re-implemented. 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 If a data directory was specified at ICU build time ``

#define ICU_DATA_DIR "path"

use that, otherwise no data directory is available.

Returns
  the data directory, or an empty string ("") if no data directory has been specified.

Stable:
  ICU 2.0

## ◆ u_getTimeZoneFilesDirectory()

U_CAPI const char * u_getTimeZoneFilesDirectory | ( | UErrorCode * | status | ) |

Return the time zone files override directory, or an empty string if no directory was specified.

Certain time zone resources will be preferentially loaded from individual files in this directory.

Returns
  the time zone data override directory.

Internal:
  Do not use. This API is for internal use only.

## ◆ u_setDataDirectory()

U_CAPI void u_setDataDirectory | ( | const char * | directory | ) |

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 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.

Parameters

  directory | The directory to be set.

See also
  u_init

Stable:
  ICU 2.0

## ◆ u_setTimeZoneFilesDirectory()

U_CAPI void u_setTimeZoneFilesDirectory | ( | const char * | path,
|  | UErrorCode * | status
| ) |  |

Set the time zone files override directory.

This function is not thread safe; it must not be called concurrently with u_getTimeZoneFilesDirectory() or any other use of ICU time zone functions. This function should only be called before using any ICU service that will access the time zone data.

Internal:
  Do not use. This API is for internal use only.

## ◆ u_UCharsToChars()

U_CAPI void u_UCharsToChars | ( | const UChar * | us,
|  | char * | cs,
|  | 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.

Parameters

  us | Input string, points to `length` Unicode characters that can be encoded with the codepage-invariant subset of the platform encoding.
  cs | Output string, points to memory for `length` character bytes.
  length | The number of characters to convert; this may include the terminating `NUL`.

See also
  U_CHARSET_FAMILY

Stable:
  ICU 2.0