Converts a path from Unicode to the local display's code page, providing the caller with full control of mapping and handling unmappable characters.
#include <unilib.h> int uninx2locpath ( UniRuleTable_t table, char *dest, size_t *destLen, const unicode_t *src, size_t srcLen, Uni2LocNoMapFunc_t noMapFunc, void *noMapFuncParm, int noMapFlag, size_t *dryRunSize );
(IN) Specifies the table to use in the conversion. To use the host's default code page, specify UNI_LOCAL_DEFAULT. Otherwise, specify the value returned from the UniGetTable function.
(OUT) Points to the converted path.
(IN/OUT) Points to the maximum number of bytes that the destination path can hold when the function is called. When the function returns, it contains the number of bytes in the converted path.
(IN) Points to the source path.
(IN) Specifies the number of Unicode characters in the source path.
(IN) Specifies the function to call when unmappable characters are found.
(IN) Points to an optional value for the noMapFunc function, which you can use in your noMapFunc function to distinguish between uses of the function. Whatever value you pass here, that value is passed to the no-map function when the uninx2locpath function encounters a character that is not in its tables.
(IN) Specifies whether to replace an unmappable character or simply return an error. It uses one of the following flags, but only the UNI_MAP_BY_FUNC flag enables calling the noMapFunc function.
(IN) Indicates whether to perform the conversion or merely compute the size of the converted string.
To perform the conversion, pass NULL.
To calculate the size of the converted string, pass the address of a variable of type size_t. In this parameter, the function returns the number of characters that would be consumed in dest if the function were to perform the actual conversion. No conversion is performed. The count includes only the number of characters and does not include any null-terminating characters.
If successful, returns 0. Otherwise, returns a negative error code:
The function you provide for the noMapFunc parameter must conform to the following syntax:
typedef int (*Uni2LocNoMapFunc_t) ( char **dest, size_t remaining, const unicode_t **src, void *userParm );
(IN/OUT) Points to a pointer to the current position in the destination string. If the translation by the function results in a character output to this string, this pointer must be updated to point one character beyond it.
(IN/OUT) Specifies the number of characters in the source string that remain to be translated.
(IN/OUT) Points to a pointer to the current position in the source string.
If your noMapFunc consumes the character at this position, do not increment the pointer beyond the present position for uninx2locpath does this.
If your noMapFunc consumes n characters, increment the value by n-1.
(IN) Specifies an optional parameter for the noMapFunc function. This is the value passed to uninx2locpath in the noMapFuncParm parameter.
After your function is called, you can use it to convert the unmappable character and allow uninx2locpath to continue converting the string, or you can use your function to convert the remaining characters.