ReactOS 0.4.15-dev-7889-g76290a6
mbstowcs_nt.c
Go to the documentation of this file.
1#include <ndk/umtypes.h>
2#include <ndk/rtlfuncs.h>
3#include <string.h>
4
5#undef MB_CUR_MAX
6#define MB_CUR_MAX 2
7
8/*
9 * @implemented
10 */
11int mbtowc (wchar_t *wchar, const char *mbchar, size_t count)
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}
34
35/*
36 * @implemented
37 */
38size_t mbstowcs (wchar_t *wcstr, const char *mbstr, size_t count)
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}
65
66/* EOF */
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
NTSYSAPI WCHAR WINAPI RtlAnsiCharToUnicodeChar(LPSTR *)
#define MB_CUR_MAX
Definition: mbstowcs_nt.c:6
size_t mbstowcs(wchar_t *wcstr, const char *mbstr, size_t count)
Definition: mbstowcs_nt.c:38
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define min(a, b)
Definition: monoChain.cc:55
_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 L(x)
Definition: ntvdm.h:50
#define wchar_t
Definition: wchar.h:102
#define mbtowc(wp, cp, len)
Definition: wchar.h:155
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
char mbs[5]
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
unsigned char UCHAR
Definition: xmlstorage.h:181
__wchar_t WCHAR
Definition: xmlstorage.h:180