update for HEAD-2003091401
[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 /*
15  * @implemented
16  */
17 unsigned int _mbctolower(unsigned int c)
18 {
19     if ((c & 0xFF00) != 0) {
20         // true multibyte case conversion needed
21         if (_ismbclower(c))
22             return c + CASE_DIFF;
23     } else {
24      return _mbbtolower(c);
25     }
26     return 0;
27 }
28
29 /*
30  * @implemented
31  */
32 unsigned char * _mbslwr(unsigned char *x)
33 {
34     unsigned char  *y=x;
35
36     while (*y) {
37         if (!_ismbblead(*y)) {
38             *y = tolower(*y);
39             } else {
40                 *y=_mbctolower(*(unsigned short *)y);
41                 y++;
42         }
43     }
44     return x;
45 }