I'm trying to output Unicode that corresponds to an integer value entered by the user. This is being done on windows 10 in C++ by the way. Currently I can print Unicode with this code:
_setmode(_fileno(stdout), _O_U16TEXT);
wprintf(L"\u0006");'''
My question is, how do I attach the variable to the Unicode?
Something like this
wchar_t wstr[2] = { variable, L'\0' };
wprintf(L"%ls", wstr);
Alternatively, you can avoid the expense of wprintf
with
wchar_t wstr[2] = { variable, L'\0' };
fputws(wstr, stdout);
In both cases variable
is the integer variable you mentioned. You might want to check that is in range for a wchar_t
and you might want to add a cast to suppress any compiler warning.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.