FIX: _mbslwr Does Not Handle International Characters

ID: Q179284


The information in this article applies to:
  • The C Run Time (CRT)
    • Microsoft Visual C++, 32-bit Editions, version 5.0


SYMPTOMS

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.


STATUS

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.


MORE INFORMATION

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;
} 

Program output:


   English_United States.1252
   Before Conversion c_Upper=D6h  c_Lower=F6h
   After  Conversion c_Upper=D6h  c_Lower=F6h 

Expected output:


   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 24, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.