An example of _tcslwr with BYTE type
-
Hello, Can somebody please give me an example of _tcslwr function used with BYTE array as input? Thanks in advance.
-
Hello, Can somebody please give me an example of _tcslwr function used with BYTE array as input? Thanks in advance.
This depends on the content stored in the byte array. Because the function expects a NULL terminated string, the byte array must contain such a string. You must also know the text encoding for the stored string. Assuming your byte array contains an ASCII or ANSI string, you can call
_strlwr
:_strlwr((char *)byteArray);
The casting to
char *
avoids compiler warnings or errors becauseBYTE
is unsigned (unsigned char
). If the resulting string must be printed out later with Unicode builds, convert it using the MultiByteToWideChar function (Windows)[^]. If it is ASCII or uses the current code page of the user running the application, it can be also converting by assigning the lowered string to aCString
:CString strLwr = _strlwr((char *)byteArray);
The above will work for Unicode and multi byte builds (with Unicode builds, the string is converted to Unicode).