ReactOS 0.4.15-dev-7934-g1dc8d80
mbstowcs_nt.c File Reference
#include <ndk/umtypes.h>
#include <ndk/rtlfuncs.h>
#include <string.h>
Include dependency graph for mbstowcs_nt.c:

Go to the source code of this file.

Macros

#define MB_CUR_MAX   2
 

Functions

int mbtowc (wchar_t *wchar, const char *mbchar, size_t count)
 
size_t mbstowcs (wchar_t *wcstr, const char *mbstr, size_t count)
 

Macro Definition Documentation

◆ MB_CUR_MAX

#define MB_CUR_MAX   2

Definition at line 6 of file mbstowcs_nt.c.

Function Documentation

◆ mbstowcs()

size_t mbstowcs ( wchar_t wcstr,
const char mbstr,
size_t  count 
)

Definition at line 38 of file mbstowcs_nt.c.

39{
41 ULONG Size;
43
44 Length = (ULONG)strlen (mbstr);
45
46 if (wcstr == NULL)
47 {
49 mbstr,
50 Length);
51
52 return (size_t)(Size / sizeof(wchar_t));
53 }
54
56 (ULONG)count * sizeof(WCHAR),
57 &Size,
58 mbstr,
59 Length);
60 if (!NT_SUCCESS(Status))
61 return -1;
62
63 return (size_t)(Size / sizeof(wchar_t));
64}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:25
GLuint GLuint GLsizei count
Definition: gl.h:1545
_Use_decl_annotations_ NTSTATUS NTAPI RtlMultiByteToUnicodeN(_Out_ PWCH UnicodeString, _In_ ULONG UnicodeSize, _Out_opt_ PULONG ResultSize, _In_ PCCH MbString, _In_ ULONG MbSize)
Definition: nlsboot.c:62
_Use_decl_annotations_ NTSTATUS NTAPI RtlMultiByteToUnicodeSize(_Out_ PULONG UnicodeSize, _In_ PCCH MbString, _In_ ULONG MbSize)
Definition: nlsboot.c:93
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define wchar_t
Definition: wchar.h:102
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ mbtowc()

int mbtowc ( wchar_t wchar,
const char mbchar,
size_t  count 
)

Definition at line 11 of file mbstowcs_nt.c.

12{
13 UCHAR mbarr[MB_CUR_MAX] = { 0 };
14 PUCHAR mbs = mbarr;
15 WCHAR wc;
16
17 if (mbchar == NULL)
18 return 0;
19
20 if (wchar == NULL)
21 return 0;
22
23 memcpy(mbarr, mbchar, min(count, sizeof mbarr));
24
26
27 if (wc == L' ' && mbarr[0] != ' ')
28 return -1;
29
30 *wchar = wc;
31
32 return (int)(mbs - mbarr);
33}
NTSYSAPI WCHAR WINAPI RtlAnsiCharToUnicodeChar(LPSTR *)
#define MB_CUR_MAX
Definition: mbstowcs_nt.c:6
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define min(a, b)
Definition: monoChain.cc:55
#define L(x)
Definition: ntvdm.h:50
unsigned char * PUCHAR
Definition: typedefs.h:53
char mbs[5]
unsigned char UCHAR
Definition: xmlstorage.h:181