:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[reactos.git] / lib / msvcrt / mbstring / mbslwr.c
1 #include <msvcrt/mbstring.h>
2 #include <msvcrt/ctype.h>
3
4 unsigned int _mbbtolower(unsigned int c)
5 {
6         if (!_ismbblead(c) )
7                 return tolower(c);
8         return c;
9 }
10
11 // code page 952
12 #define CASE_DIFF (0x8281 - 0x8260)
13
14 unsigned int _mbctolower(unsigned int c)
15 {
16   if ((c & 0xFF00) != 0)
17     {
18       // true multibyte case conversion needed
19       if (_ismbclower(c))
20         return c + CASE_DIFF;
21     }
22   else
23      return _mbbtolower(c);
24
25   return 0;
26 }
27
28 unsigned char * _mbslwr(unsigned char *x)
29 {
30   unsigned char  *y=x;
31
32   while (*y)
33     {
34       if (!_ismbblead(*y))
35         {
36           *y = tolower(*y);
37         }
38       else
39         {
40           *y=_mbctolower(*(unsigned short *)y);
41           y++;
42         }
43     }
44   return x;
45 }