Converts a string from a local code page to Unicode, providing the caller with full control of the mapping and handling of unmappable characters.
#include <unilib.h>
int locnx2uni (
UniRuleTable_t table,
unicode_t *dest,
size_t *destLen,
const char *src,
size_t srcLen,
Loc2UniNoMapFunc_t noMapFunc,
void *noMapFuncParm,
int noMapFlag);
(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 string.
(IN/OUT) Points to the maximum number of Unicode characters that the destination string can hold when the function is called. When the function returns, it contains the number of Unicode characters in the converted string.
(IN) Points to the source string.
(IN) Specifies the number of bytes in the source string.
(IN) Specifies the function to call when unmappable characters are found. See Remarks for the prototype.
(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 noMapFunc function when the locnx2uni 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.
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 (*Loc2UniNoMapFunc_t)
( unicode_t **dest,
size_t remaining,
const char **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 because locnx2uni 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 locnx2uni in the noMapFuncParm parameter.
After your function is called, you can use it to convert the unmappable character and allow locnx2uni to continue converting the string, or you can use your function to convert the remaining characters.