I am to print some unicode (4 digit Hex) characters in C.
Those characters I've stored in some short int variables. The following is the code I'm supposed to use for my purpose :
#include <stdio.h>
#include <locale.h>
#include <wchar.h>
int main(void) {
setlocale(LC_ALL,"");
short a = 0x099A, b = 0x09BE;
wchar_t *string1 = (wchar_t *) calloc(20, sizeof(wchar_t));
sprintf(string1, "\\u%04x\\u%04x", a, b);
printf(" %s ", string1);
wchar_t *string2 = (wchar_t *) calloc(20, sizeof(wchar_t));
strcpy(string2, (wchar_t *) "\u099A\u09BE");
printf(" %s \n", string2);
return 0;
}
Now the problem is:
although string2 is showing the corect output in terminal, string1 isn't.
But I must use the 1st approach, i.e I have the unicode characters stored in some arbitrary variables & I need a way to get them printed on screen.
Any suggestion shall be keenly appreciated.