Q:

C++ : Print value of unsigned short variable as unicode character

I want to be print a Bengali letter to the console, given that the UTF-16 lower 2 bytes for that letter are stored in an unsigned short variable.
For example, for the letter অ (Reference : অ)
The unicode value is - 0985(hex)
And I have, unsigned short unicodeChar = 0x0985;
Now, how can I print this letter অ using the value of unicodeChar?
Note: I've tried this- cout << "\u0985"; and it prints অ properly.
But I want to be able to print the character represented by the variable unicodeChar

A:

Try to use const char* to store the value.
#include <iostream>

using namespace std;
int main()
{
    const char* uC = "\u0985";
    cout << uC << endl;
}

If you want to use the value of unsigned short, you can use setlocale and print it by %lc:
#include <stdio.h>
#include <locale.h>
int main()
{
    if (!setlocale(LC_CTYPE, ""))
    {
        fprintf(stderr, "Error:Please check LANG, LC_CTYPE, LC_ALL.\n");
        return 1;
    }

    unsigned short unicodeChar = 0x0985;
    printf ("%lc\n",unicodeChar);
}

