Enter ANSI, and Unicode Character Encoding

Been developing a lot in .NET and C/C++ and been overwhelm by the fact that character encoding plays a part in building applications. One might not know that it existed under the hood but understanding why they are there is crucial to getting different quirks and bugs.

In laymen term each machine or computers have a standard default character encoding that translates each character to a byte and multi-byte (Unicode). Mostly nowadays Unicode is used to support wide variety of characters from native English alphabet to other non-english like Chinese, Japanese etc.

Check the link below for a very thorough explanation and more about character and coding and types in Windows system.

Including _T(TCHAR) macro that tells the compiler to use char or wchar_t and L”Literal” to interpret the string as a unicode multibyte string.

Copied and Pasted from the article:
The ## symbol is token pasting operator, which would turn _T("Unicode") into L"Unicode", where the string passed is argument to macro – If _UNICODE is defined. If _UNICODE is not defined, _T("Unicode") would simply mean "Unicode". The token pasting operator did exist even in C language, and is not specific about VC++ or character encoding.

Note that these macros can be used for strings as well as characters. _T('R') would turn into L'R' or simple 'R' – former is Unicode character, latter is ANSI character.

No, you cannot use these macros to convert variables (string or character) into Unicode/non-Unicode text

https://www.codeproject.com/Articles/76252/What-are-TCHAR-WCHAR-LPSTR-LPWSTR-LPCTSTR-etc

Leave a Reply

Your email address will not be published. Required fields are marked *