mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 15:23:04 +00:00
Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys.
This commit is contained in:
parent
b94e2d8ca0
commit
c2c66aff7d
24198 changed files with 0 additions and 37285 deletions
66
sdk/lib/crt/string/mbstowcs_nt.c
Normal file
66
sdk/lib/crt/string/mbstowcs_nt.c
Normal file
|
@ -0,0 +1,66 @@
|
|||
#include <ndk/umtypes.h>
|
||||
#include <ndk/rtlfuncs.h>
|
||||
#include <string.h>
|
||||
|
||||
#undef MB_CUR_MAX
|
||||
#define MB_CUR_MAX 2
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int mbtowc (wchar_t *wchar, const char *mbchar, size_t count)
|
||||
{
|
||||
UCHAR mbarr[MB_CUR_MAX] = { 0 };
|
||||
PUCHAR mbs = mbarr;
|
||||
WCHAR wc;
|
||||
|
||||
if (mbchar == NULL)
|
||||
return 0;
|
||||
|
||||
if (wchar == NULL)
|
||||
return 0;
|
||||
|
||||
memcpy(mbarr, mbchar, min(count, sizeof mbarr));
|
||||
|
||||
wc = RtlAnsiCharToUnicodeChar(&mbs);
|
||||
|
||||
if (wc == L' ' && mbarr[0] != ' ')
|
||||
return -1;
|
||||
|
||||
*wchar = wc;
|
||||
|
||||
return (int)(mbs - mbarr);
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
size_t mbstowcs (wchar_t *wcstr, const char *mbstr, size_t count)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
ULONG Size;
|
||||
ULONG Length;
|
||||
|
||||
Length = (ULONG)strlen (mbstr);
|
||||
|
||||
if (wcstr == NULL)
|
||||
{
|
||||
RtlMultiByteToUnicodeSize (&Size,
|
||||
mbstr,
|
||||
Length);
|
||||
|
||||
return (size_t)(Size / sizeof(wchar_t));
|
||||
}
|
||||
|
||||
Status = RtlMultiByteToUnicodeN (wcstr,
|
||||
(ULONG)count * sizeof(WCHAR),
|
||||
&Size,
|
||||
mbstr,
|
||||
Length);
|
||||
if (!NT_SUCCESS(Status))
|
||||
return -1;
|
||||
|
||||
return (size_t)(Size / sizeof(wchar_t));
|
||||
}
|
||||
|
||||
/* EOF */
|
Loading…
Add table
Add a link
Reference in a new issue