FIX: _mbslwr Does Not Handle International CharactersID: Q179284
|
The C run-time function _mbslwr is used to convert uppercase letters in a multibyte-character string to lowercase letters. This function fails to convert characters that are in the range of 128 to 255.
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug was corrected in Microsoft Visual Studio 97 service pack and in Microsoft Visual C++ version 6.0.
The following sample program demonstrates the problem:
//Sample.cpp
// Compiler Options: none
#include <stdio.h>
#include <locale.h>
#include <mbstring.h>
int main()
{
printf("%s\n",setlocale(LC_ALL,"English_United States.1252") );
unsigned char c_Upper = '\xD6' ;
//Capital O Umlaut character value=D6h.
unsigned char c_Lower = '\xF6' ;
//Lower Case O Umlaut character value=F6h.
printf( "Before Conversion c_Upper=%Xh c_Lower=%Xh\n",
c_Upper, c_Lower );
_mbslwr(&c_Upper); // c_Upper should now be equal to c_Lower =F6h
printf( "After Conversion c_Upper=%Xh c_Lower=%Xh\n",
c_Upper, c_Lower );
return 0;
}
English_United States.1252
Before Conversion c_Upper=D6h c_Lower=F6h
After Conversion c_Upper=D6h c_Lower=F6h
English_United States.1252
Before Conversion c_Upper=D6h c_Lower=F6h
After Conversion c_Upper=F6h c_Lower=F6h
Additional query words: VS97FixlistSP1 CString MakeLower
Keywords : kbCRT kbVC500bug kbVC600fix kbVS600SP1fix
Version : WINNT:5.0
Platform : winnt
Issue type : kbbug
Last Reviewed: July 23, 1999