ReactOS 0.4.16-dev-927-g467dec4
towlower.cpp File Reference
#include <corecrt_internal.h>
#include <ctype.h>
#include <locale.h>
Include dependency graph for towlower.cpp:

Go to the source code of this file.

Functions

wint_t __cdecl _towlower_l (wint_t const c, _locale_t const plocinfo)
 
wint_t __cdecl towlower (wint_t c)
 

Function Documentation

◆ _towlower_l()

wint_t __cdecl _towlower_l ( wint_t const  c,
_locale_t const  plocinfo 
)

Definition at line 28 of file towlower.cpp.

32{
33 if (c == WEOF)
34 {
35 return c;
36 }
37
38 _LocaleUpdate _loc_update(plocinfo);
39 auto const locinfo = _loc_update.GetLocaleT()->locinfo;
40
41 if (locinfo->_public._locale_lc_codepage == CP_UTF8)
42 {
43 // For 128 <= c < 256, the tolower map would consider the wide character as it is in UTF-8, not UTF-16.
44 // Below 128, UTF-8 and UTF-16 have the same encodings, so we can use the table.
45 if (c < 128)
46 {
47 return _towlower_fast_internal(static_cast<unsigned char>(c), _loc_update.GetLocaleT());
48 }
49 }
50 else
51 {
52 // For 128 <= c < 256, the tolower map will consider the wide character as it would be in the current narrow code page,
53 // which can lead to unexpected behavior. This behavior is maintained for backwards compatibility.
54 if (c < 256)
55 {
56 return _towlower_fast_internal(static_cast<unsigned char>(c), _loc_update.GetLocaleT());
57 }
58
59 if (locinfo->locale_name[LC_CTYPE] == nullptr)
60 {
61 // If the locale is C, then the only characters that would be transformed are <256
62 // and have been processed already.
63 return c;
64 }
65 }
66
67 wint_t widechar;
68 if (0 == __acrt_LCMapStringW(
69 locinfo->locale_name[LC_CTYPE],
71 (LPCWSTR)&c,
72 1,
73 (LPWSTR)&widechar,
74 1))
75 {
76 return c;
77 }
78
79 return widechar;
80}
int __cdecl __acrt_LCMapStringW(LPCWSTR const locale_name, DWORD const map_flags, LPCWSTR const source, int source_count, LPWSTR const destination, int const destination_count)
int wint_t
Definition: _apple.h:38
_Check_return_ __forceinline wint_t _towlower_fast_internal(_In_ unsigned char const c, _In_ _locale_t const locale)
const GLubyte * c
Definition: glext.h:8905
#define LC_CTYPE
Definition: locale.h:19
_locale_t plocinfo
Definition: ismbbyte.cpp:75
#define c
Definition: ke_i.h:80
else locinfo
Definition: scanf.h:159
#define WEOF
Definition: conio.h:185
#define CP_UTF8
Definition: nls.h:20
#define LCMAP_LOWERCASE
Definition: winnls.h:186
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by towlower().

◆ towlower()

wint_t __cdecl towlower ( wint_t  c)

Definition at line 99 of file towlower.cpp.

102{
103
104 return _towlower_l(c, nullptr);
105}
wint_t __cdecl _towlower_l(wint_t const c, _locale_t const plocinfo)
Definition: towlower.cpp:28