DCMTK Version 3.6.8
OFFIS DICOM Toolkit
|
Type definitions, constants and functions for the oficonv module. More...
Classes | |
struct | iconv_allocation_t |
space holder type for OFiconv_open_into(). More... | |
struct | iconv_hooks |
callback data struct for OFiconvctl() with ICONV_SET_HOOKS operation More... | |
struct | iconv_locale_allocation_t |
space holder type for OFlocale_charset(). More... | |
Macros | |
#define | _ICONV_VERSION 0x0108 |
iconv library version constant, indicating that we have iconvctl() | |
#define | ICONV_TRIVIALP 0 |
OFiconvctl() request macro. More... | |
#define | ICONV_GET_TRANSLITERATE 1 |
OFiconvctl() request macro. More... | |
#define | ICONV_SET_TRANSLITERATE 2 |
OFiconvctl() request macro. More... | |
#define | ICONV_GET_DISCARD_ILSEQ 3 |
OFiconvctl() request macro. More... | |
#define | ICONV_SET_DISCARD_ILSEQ 4 |
OFiconvctl() request macro. More... | |
#define | ICONV_SET_HOOKS 5 |
OFiconvctl() request macro. More... | |
#define | ICONV_SET_FALLBACKS 6 |
OFiconvctl() request macro. More... | |
#define | ICONV_GET_ILSEQ_INVALID 128 |
OFiconvctl() request macro. More... | |
#define | ICONV_SET_ILSEQ_INVALID 129 |
OFiconvctl() request macro. More... | |
Typedefs | |
typedef void(* | iconv_unicode_char_hook) (unsigned int mbr, void *data) |
callback function type for unicode char hook | |
typedef void(* | iconv_wide_char_hook) (_citrus_wc_t wc, void *data) |
callback function type for wide char hook | |
typedef void(* | oficonv_logger_callback_t) (int level, const char *text1, const char *text2, const char *text3) |
logger callback function pointer type More... | |
Functions | |
BEGIN_EXTERN_C DCMTK_OFICONV_EXPORT iconv_t | OFiconv_open (const char *dstname, const char *srcname) |
open a converter from the codeset srcname to the codeset dstname and returns its descriptor. More... | |
DCMTK_OFICONV_EXPORT size_t | OFiconv (iconv_t cd, char **src, size_t *srcleft, char **dst, size_t *dstleft) |
convert the string in the buffer *src of length *srcleft bytes and stores the converted string in the buffer *dst of size *dstleft bytes. More... | |
DCMTK_OFICONV_EXPORT int | OFiconv_close (iconv_t cd) |
close the specified converter cd More... | |
DCMTK_OFICONV_EXPORT int | OF__iconv_get_list (char ***names, size_t *count, __iconv_bool paired) |
obtain a list of character encodings that are supported by the OFiconv() call. More... | |
DCMTK_OFICONV_EXPORT void | OF__iconv_free_list (char **names, size_t count) |
free the allocated memory during the call of OF__iconv_get_list(). More... | |
DCMTK_OFICONV_EXPORT size_t | OF__iconv (iconv_t cd, char **src, size_t *srcleft, char **dst, size_t *dstleft, uint32_t flags, size_t *invalids) |
The OF__iconv() function works just like iconv() but if iconv() fails, the invalid character count is lost there. More... | |
DCMTK_OFICONV_EXPORT int | OFiconv_open_into (const char *dstname, const char *srcname, iconv_allocation_t *ptr) |
create a conversion descriptor on a preallocated space. More... | |
DCMTK_OFICONV_EXPORT int | OFiconv_close_in (iconv_allocation_t *ptr) |
close the converter cd allocated in ptr More... | |
DCMTK_OFICONV_EXPORT void | OFiconvlist (int(*do_one)(unsigned int count, const char *const *names, void *arg), void *arg) |
The iconvlist() function obtains a list of character encodings that are supported by the OFiconv() call. More... | |
DCMTK_OFICONV_EXPORT const char * | OFiconv_canonicalize (const char *name) |
resolve the character encoding name specified by the name argument to its canonical form. More... | |
DCMTK_OFICONV_EXPORT int | OFiconvctl (iconv_t cd, int request, void *argument) |
This function can retrieve or set specific conversion setting from the cd conversion descriptor. More... | |
DCMTK_OFICONV_EXPORT const char * | OFlocale_charset (iconv_locale_allocation_t *buf) |
Determine the current locale's character encoding, and canonicalize it. More... | |
DCMTK_OFICONV_EXPORT void | set_oficonv_logger_callback (oficonv_logger_callback_t callback) |
set the logger callback to be used by the oficonv module. More... | |
DCMTK_OFICONV_EXPORT oficonv_logger_callback_t | get_oficonv_logger_callback () |
get the current logger callback used by the oficonv module More... | |
DCMTK_OFICONV_EXPORT void | set_oficonv_log_level (int level) |
set the log level to be used as long as direct logging to stderr is active More... | |
Variables | |
int | _iconv_version |
iconv library version constant, value defaults to _ICONV_VERSION | |
Type definitions, constants and functions for the oficonv module.
struct iconv_allocation_t |
space holder type for OFiconv_open_into().
struct iconv_hooks |
callback data struct for OFiconvctl() with ICONV_SET_HOOKS operation
struct iconv_locale_allocation_t |
space holder type for OFlocale_charset().
#define ICONV_GET_DISCARD_ILSEQ 3 |
OFiconvctl() request macro.
Determines if illegal sequences are discarded or not. The answer is stored in argument, which is of int *. It will be set to 1 if this feature is enabled or set to 0 otherwise.
#define ICONV_GET_ILSEQ_INVALID 128 |
OFiconvctl() request macro.
Determines if a character in the input buffer that is valid, but for which an identical character does not exist in the target codeset returns EILSEQ or not. The answer is stored in argument, which is of int *. It will be set to 1 if this feature is enabled or set to 0 otherwise.
#define ICONV_GET_TRANSLITERATE 1 |
OFiconvctl() request macro.
Determines if transliteration is enabled. The answer is stored in argument, which is of int *. It will be set to 1 if this feature is enabled or set to 0 otherwise.
#define ICONV_SET_DISCARD_ILSEQ 4 |
OFiconvctl() request macro.
Sets whether illegal sequences are discarded or not. argument, which is of int * set to 1 or disables it if argument is set to 0.
#define ICONV_SET_FALLBACKS 6 |
OFiconvctl() request macro.
Currently unsupported, will always return an error
#define ICONV_SET_HOOKS 5 |
OFiconvctl() request macro.
Sets callback functions, which will be called back after successful conversions. The callback functions are stored in a struct iconv_hooks variable, which is passed to iconvctl via argument by its address.
#define ICONV_SET_ILSEQ_INVALID 129 |
OFiconvctl() request macro.
Sets whether a character in the input buffer that is valid, but for which an identical character does not exist in the target codeset returns EILSEQ or not. If argument, which is of int * is set to 1 it will be enabled, and if argument is set to 0 it will be disabled.
#define ICONV_SET_TRANSLITERATE 2 |
OFiconvctl() request macro.
Enables transliteration if argument, which is of int * set to 1 or disables it if argument is set to 0.
#define ICONV_TRIVIALP 0 |
OFiconvctl() request macro.
The argument is an int * variable, which is set to 1 if the encoding is trivial one, i.e. the input and output encodings are the same. Otherwise, the variable will be 0.
typedef void(* oficonv_logger_callback_t) (int level, const char *text1, const char *text2, const char *text3) |
logger callback function pointer type
level | log level, 0=trace, 1=debug, 2=info, 3=warn, 4=error, 5=fatal |
text1 | first part of the string to be logged, must not be NULL |
text2 | second part of the string to be logged, must not be NULL |
text3 | third part of the string to be logged, must not be NULL |
DCMTK_OFICONV_EXPORT oficonv_logger_callback_t get_oficonv_logger_callback | ( | ) |
get the current logger callback used by the oficonv module
DCMTK_OFICONV_EXPORT size_t OF__iconv | ( | iconv_t | cd, |
char ** | src, | ||
size_t * | srcleft, | ||
char ** | dst, | ||
size_t * | dstleft, | ||
uint32_t | flags, | ||
size_t * | invalids | ||
) |
The OF__iconv() function works just like iconv() but if iconv() fails, the invalid character count is lost there.
This is a not bug, rather a limitation of IEEE Std 1003.1-2008 (POSIX.1), so OF__iconv() is provided as an alternative but non-standard interface.
cd | conversion descriptor returned by OFiconv_open() |
src | address of pointer to first byte in source buffer |
srcleft | address of variable containing the number of bytes left in the source buffer |
src | address of pointer to first byte in destination buffer |
srcleft | address of variable containing the number of bytes left in the destination buffer |
flags | conversion flags. Currently only zero (default) or __ICONV_F_HIDE_INVALID can be passed. If __ICONV_F_HIDE_INVALID is passed, invalid characters are skipped instead of returning with an error. |
invalids | address of variable in which the number of conversions to "invalid character" is returned upon success or failure |
DCMTK_OFICONV_EXPORT void OF__iconv_free_list | ( | char ** | names, |
size_t | count | ||
) |
free the allocated memory during the call of OF__iconv_get_list().
names | address of char pointer array created by OF__iconv_get_list() |
count | number of entries in char pointer array |
DCMTK_OFICONV_EXPORT int OF__iconv_get_list | ( | char *** | names, |
size_t * | count, | ||
__iconv_bool | paired | ||
) |
obtain a list of character encodings that are supported by the OFiconv() call.
The list of the encoding names will be stored in names and the number of the entries is stored in count.
names | address of char pointer array returned in this parameter |
count | number of entries in char pointer array returned in this parameter |
paired | if true, the list will be arranged into canonical/alias name pairs. |
DCMTK_OFICONV_EXPORT size_t OFiconv | ( | iconv_t | cd, |
char ** | src, | ||
size_t * | srcleft, | ||
char ** | dst, | ||
size_t * | dstleft | ||
) |
convert the string in the buffer *src of length *srcleft bytes and stores the converted string in the buffer *dst of size *dstleft bytes.
After calling iconv(), the values pointed to by src, srcleft, dst, and dstleft are updated as follows:
If the string pointed to by *src contains a byte sequence which is not a valid character in the source codeset, the conversion stops just after the last successful conversion. If the output buffer is too small to store the converted character, the conversion also stops in the same way. In these cases, the values pointed to by src, srcleft, dst, and dstleft are updated to the state just after the last successful conversion.
If the string pointed to by *src contains a character which is valid under the source codeset but can not be converted to the destination codeset, the character is replaced by an "invalid character" which depends on the destination codeset, e.g., '?', and the conversion is continued. iconv() returns the number of such "invalid conversions".
cd | conversion descriptor returned by OFiconv_open() |
src | address of pointer to first byte in source buffer |
srcleft | address of variable containing the number of bytes left in the source buffer |
src | address of pointer to first byte in destination buffer |
srcleft | address of variable containing the number of bytes left in the destination buffer |
DCMTK_OFICONV_EXPORT const char * OFiconv_canonicalize | ( | const char * | name | ) |
resolve the character encoding name specified by the name argument to its canonical form.
name | encoding name |
DCMTK_OFICONV_EXPORT int OFiconv_close | ( | iconv_t | cd | ) |
close the specified converter cd
cd | converter ID returned by OFiconv_open() |
DCMTK_OFICONV_EXPORT int OFiconv_close_in | ( | iconv_allocation_t * | ptr | ) |
close the converter cd allocated in ptr
ptr | pointer to conversion descriptor created with OFiconv_open_into() |
BEGIN_EXTERN_C DCMTK_OFICONV_EXPORT iconv_t OFiconv_open | ( | const char * | dstname, |
const char * | srcname | ||
) |
open a converter from the codeset srcname to the codeset dstname and returns its descriptor.
The arguments srcname and dstname accept "" and "char", which refer to the current locale encoding.
dstname | name of the destination codeset |
srcname | name of the source codeset |
DCMTK_OFICONV_EXPORT int OFiconv_open_into | ( | const char * | dstname, |
const char * | srcname, | ||
iconv_allocation_t * | ptr | ||
) |
create a conversion descriptor on a preallocated space.
The iconv_allocation_t is used as a spaceholder type when allocating such space. The dstname and srcname arguments are the same as in the case of iconv_open(). The ptr argument is a pointer of iconv_allocation_t to the preallocated space.
dstname | name of the destination codeset |
srcname | name of the source codeset |
ptr | pointer to block of memory in which the conversion descriptor is allocated After successful completion of this function, ptr can be safely casted to iconv_t and used with OFiconv(). The conversion descriptor must be closed using OFiconv_close_in(), not with OFiconv_close(). |
DCMTK_OFICONV_EXPORT int OFiconvctl | ( | iconv_t | cd, |
int | request, | ||
void * | argument | ||
) |
This function can retrieve or set specific conversion setting from the cd conversion descriptor.
The request parameter specifies the operation to accomplish and argument is an operation-specific argument.
cd | conversion description |
request | OFiconvctl() request macro defining the operation to be performed |
argument | pointer to data for the the requested operation, see description of request macros |
DCMTK_OFICONV_EXPORT void OFiconvlist | ( | int(*)(unsigned int count, const char *const *names, void *arg) | do_one, |
void * | arg | ||
) |
The iconvlist() function obtains a list of character encodings that are supported by the OFiconv() call.
The do_one() callback function will be called, where the count argument will be set to the number of the encoding names found, the names argument will be the list of the supported encoding names and the arg argument will be the arg argument of the iconvlist() function. This argument can be used to interchange custom data between the caller of iconvlist() and the callback function. If an error occurs, names will be NULL when calling do_one().
do_one | callback function |
arg | opaque pointer that will be passed to the callback function |
DCMTK_OFICONV_EXPORT const char * OFlocale_charset | ( | iconv_locale_allocation_t * | buf | ) |
Determine the current locale's character encoding, and canonicalize it.
The result must not be freed; it is statically allocated. If the canonical name cannot be determined, the result is a non-canonical name.
buf | buffer to which the current encoding is written on Windows |
DCMTK_OFICONV_EXPORT void set_oficonv_log_level | ( | int | level | ) |
set the log level to be used as long as direct logging to stderr is active
level | log level, 0=trace, 1=debug, 2=info, 3=warn, 4=error, 5=fatal (default: 3=warn) |
DCMTK_OFICONV_EXPORT void set_oficonv_logger_callback | ( | oficonv_logger_callback_t | callback | ) |
set the logger callback to be used by the oficonv module.
This function is thread UNSAFE.
callback | pointer to callback function, NULL for direct logging to stderr |