The following are some common tasks you need to perform when using an extended converter:
If you have not already done so, call NWUXLoadByteUnicodeConverter. Specify the relevant code page for the codepage parameter.
Supply a buffer of sufficient length to hold the Unicode output string. If length is important to your application and is not known follow the steps in
Call NWUXByteToUnicode or NWUXLenByteToUnicode unless the string is a path. For path strings, call NWUXByteToUnicodePath or NWUXLenByteToUnicodePath
If you have called NWUXByteToUnicode to determine the required length of the output buffer, call NWUXByteToUnicode a second time. This time use outLength from the returned previous call to determine the required length for the output buffer.
Use the returned Unicode string as needed.
When you no longer need the converter, free it by calling NWUXUnicodeRelease and passing the relevant converter handle.
For related information, see Converting Unicode to Bytes with an Extended Converter
If you have not already done so, call NWUXLoadByteUnicodeConverter. Specify the relevant code page for the codepage parameter.
Supply a buffer of sufficient length to hold the byte output string. If you don’t know that length, see Determining Output String Length with an Extended Converter.
Call NWUXUnicodeToByte with the following parameter specifications:
If you have called NWUXUnicodeToByte to determine the required length of the output buffer, call NWUXUnicodeToByte a second time. This time use outLength from the returned previous call to determine the required length for the output buffer.
Use the returned byte string as needed.
When you no longer need the converter, free it by calling NWUXUnicodeRelease and passing the relevant converter handle.
For related information, see Converting Bytes to Unicode with an Extended Converter
If you have not done so already, call NWUXLoadByteUnicodeConverter.
Convert as explained in Converting Bytes to Unicode with an Extended Converter or Converting Unicode to Bytes with an Extended Converter, but call one of the following path-specific functions:
NOTE:Although the example in this task is written to convert from byte to Unicode, the same general procedure can be used for determining output string length for any extended conversion.
If you have not done so already, call the appropriate function to load the required converter:
With the converter loaded, call the appropriate conversion function once to determine the required length of the output buffer. Pass a NULL for the output buffer parameter.
NWUXByteToUnicode(converter, NULL, 0, inbuf, &actualLength);
When the function returns, the actualLength parameter points to the output string length.
NOTE:The length pointed to is only the number of characters in the string. It does not include a NULL terminator.
Add one the returned actualLength for the NULL terminator. If the output is to be a Unicode string, multiply actualLength by sizeof(unicode) to get the required number of bytes. Then allocate memory.
bufsiz=acutalLen+1;
outbuf=(punicode)malloc(bufsize*sizeof(unicode));
Do the real conversion.
NWUXByteToUnicode(converter, outbuf, bufsize, inbuf, NULL);
When the converter is no longer needed, free the output buffer and call NWUXUnloadConverter as explained in Unloading Converters.
For related information, see:
By default, the extended Unicode API uses the Default Conversion Behavior. However, the developer can change that process in several ways:
Change the NoMap action
Change the Substitution character
Change the handler function
Change scan/parse functions
To make a change, then reset functions to pre-change behavior:
To change the NoMap action, call NWUXSetNoMapAction, and set the noMapByteAction or noMapUniAction to
Set either of these parameters to NWU_UNCHANGED_ACTION if no change is needed.
The change the substitution character, call NWUXSetSubByte or NWUXSetSubUni and set the substituteByte or substituteUni parameter to the new substitution character.
To change the function handler, call NWUXSetByteFunctions or NWUXSetUniFunctions and set the noMapByteFunc or noMapUniFunc parameter to point to the new function.
To return all settings to the system defaults, call NWUXResetConverter and pass the handle of the converter.
For related information, see:
Substitution characters can be used as one option to replace unmappable characters in either Unicode-to-byte or byte-to-Unicode conversions. The other options are to return an error or to call a handler function.
If you have not already done so, call NWUXLoadByteUnicodeConverter to initialize the converter and obtain a converter handle.
If you need to save and restore the original substitution character, call the appropriate function to obtain current substitution character information:
Call the appropriate function to set a new substitution character:
Convert the strings as needed.
When the most recently set substitution characters are no longer needed, reset as appropriate:
When the converter is not longer needed, call NWUXUnloadConverter, passing the appropriate converter handle.
For related information, see:
If you have not already done so, call NWUXLoadByteUnicodeConverter. Specify the relevant code page for the codepage parameter.
If you want to return to the current settings after a change, call the Get version of the relevant function and save the return before calling the Set function to make the change.
The enable or disable scan/parse functions, call NWUXSetScanAction and set either the scanByteAction or the scanUniAction parameter to
Pass NWU_UNCHANGED to either parameter that requires no change.
The default is disabled for Unicode-to-byte conversion and enabled for byte-to-Unicode conversion.
To set either a scan or parse (or both) function other than the default system functions, call NWUXSetByteFunctions or NWUXSetUniFunctions and pass a pointer to the new function(s). Pass NWU_UNCHANGED_FUNCTION to pointers in these functions for which not change is needed.
For related information, see: