ReactOS 0.4.16-dev-852-gcfcc8d8
GetStringTypeA.cpp File Reference
#include <corecrt_internal.h>
#include <locale.h>
Include dependency graph for GetStringTypeA.cpp:

Go to the source code of this file.

Functions

BOOL __cdecl __acrt_GetStringTypeA (_locale_t const locale, DWORD const info_type, LPCSTR const string, int const string_size_in_bytes, unsigned short *const char_type, int const code_page, BOOL const error)
 

Function Documentation

◆ __acrt_GetStringTypeA()

BOOL __cdecl __acrt_GetStringTypeA ( _locale_t const  locale,
DWORD const  info_type,
LPCSTR const  string,
int const  string_size_in_bytes,
unsigned short *const  char_type,
int const  code_page,
BOOL const  error 
)

Definition at line 43 of file GetStringTypeA.cpp.

52{
53 _LocaleUpdate locale_update(locale);
54
55 // Convert string and return the requested information. Note that
56 // we are converting to a wide character string so there is not a
57 // one-to-one correspondence between number of multibyte chars in the
58 // input string and the number of wide chars in the buffer. However,
59 // there had *better be* a one-to-one correspondence between the
60 // number of multibyte characters and the number of WORDs in the
61 // return buffer.
62
63 // Use __lc_codepage for conversion if code_page not specified:
64 int const actual_code_page = code_page != 0
65 ? code_page
66 : locale_update.GetLocaleT()->locinfo->_public._locale_lc_codepage;
67
68 // Find out how big a buffer we need:
69 int const required_extent = __acrt_MultiByteToWideChar(
70 actual_code_page,
72 string,
73 string_size_in_bytes,
74 nullptr,
75 0);
76
77 if (required_extent == 0)
78 return FALSE;
79
80 // Allocate enough space for the wide character string:
81 __crt_scoped_stack_ptr<wchar_t> buffer(_malloca_crt_t(wchar_t, required_extent));
82 if (buffer.get() == nullptr)
83 return FALSE;
84
85 memset(buffer.get(), 0, sizeof(wchar_t) * required_extent);
86
87 // Do the conversion:
88 int const actual_extent = __acrt_MultiByteToWideChar(
89 actual_code_page,
91 string,
92 string_size_in_bytes,
93 buffer.get(),
94 required_extent);
95
96 if (actual_extent == 0)
97 return FALSE;
98
99 return GetStringTypeW(info_type, buffer.get(), actual_extent, char_type);
100}
Definition: _locale.h:75
_Out_opt_ UINT * code_page
#define FALSE
Definition: types.h:117
BOOL WINAPI GetStringTypeW(DWORD type, LPCWSTR src, INT count, LPWORD chartype)
Definition: locale.c:3095
GLuint buffer
Definition: glext.h:5915
#define MB_ERR_INVALID_CHARS
Definition: unicode.h:41
#define error(str)
Definition: mkdosfs.c:1605
#define memset(x, y, z)
Definition: compat.h:39
#define MB_PRECOMPOSED
Definition: winnls.h:283

Referenced by __acrt_locale_initialize_ctype(), _isctype_l(), _wsetlocale_set_cat(), and setSBUpLow().