3.2 Example: NWGetLocalToUnicodeHandle
/* exul2u.c - NWGetLocalToUnicodeHandle / NWLocalToUnicode example */
#define NWL_EXCLUDE_TIME
#define NWL_EXCLUDE_FILE
#include <nwlocale.h>
#include <unicode.h>
#include <string.h>
#include <assert.h>
void main()
{
LCONV lconv;
nint err;
nptr h = NULL;
nuint8 src[5] = {’a’, ’b’, ’c’, ’d’, 0}; /* Local input string */
unicode dest[5];
nuint8 noMap = 0; /* Use the default replacement char. */
nuint len;
/* Get the country ID and code page from the operating system. */
NWLlocaleconv(&lconv);
err = NWInitUnicodeTables(lconv.country_id, lconv.code_page);
assert (err == 0);
err = NWGetLocalToUnicodeHandle(&h);
assert (err == 0);
err = NWLocalToUnicode(h, dest, sizeof(dest), src, noMap, &len);
assert (err == 0);
assert (unicmp(dest, L"abcd") == 0); /* Unicode output string */
assert (len == 5); /* Output size includes null */
NWFreeUnicodeTables();
}