The code presented in the question,
CHAR chDecimal = 'A';
TCHAR Decimal = '\0';
int written = MultiByteToWideChar(CP_ACP, 0, &chDecimal, 1, &Decimal, 1);
does not convert to TCHAR
(which depends on whether UNICODE
is defined), as is claimed. Instead it unconditionally converts to wchar_t
. Also, using the Microsoft T
stuff, which is in support of Windows 9x and which was obsolete already in the year 2000 with the introduction of Layer for Unicode, is extremely dubious practice for non-legacy code.
Converting single encoding points is anyway a very dubious practice. It fails for any encoding scheme with more than one byte per character, such as Japanese codepages, or UTF-8.
If the intent is to convert only ASCII characters, then just copy it, using either the C++ copy assignment operator =
or initialization. Can't get simpler than that.