Added binary and unicode file i/o support to msvcrt.
[reactos.git] / reactos / lib / crtdll / 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 // true multibyte case conversion needed
18 if (_ismbclower(c))
19 return c + CASE_DIFF;
20 } else {
21 return _mbbtolower(c);
22 }
23 return 0;
24 }
25
26 unsigned char * _mbslwr(unsigned char *x)
27 {
28 unsigned char *y=x;
29
30 while (*y) {
31 if (!_ismbblead(*y)) {
32 *y = tolower(*y);
33 } else {
34 *y=_mbctolower(*(unsigned short *)y);
35 y++;
36 }
37 }
38 return x;
39 }