mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 01:05:42 +00:00
[CRT]
Patch by Thomas Faber: Fix nt version of mbstowcs. See issue #5983 for more details. svn path=/trunk/; revision=51003
This commit is contained in:
parent
c6d8f7de70
commit
031e55222a
1 changed files with 18 additions and 9 deletions
|
@ -4,26 +4,35 @@
|
||||||
#include <ndk/rtlfuncs.h>
|
#include <ndk/rtlfuncs.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
WCHAR NTAPI RtlAnsiCharToUnicodeChar(IN OUT PUCHAR *AnsiChar);
|
||||||
|
#undef MB_CUR_MAX
|
||||||
|
#define MB_CUR_MAX 2
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
int mbtowc (wchar_t *wchar, const char *mbchar, size_t count)
|
int mbtowc (wchar_t *wchar, const char *mbchar, size_t count)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
UCHAR mbarr[MB_CUR_MAX] = { 0 };
|
||||||
ULONG Size;
|
PUCHAR mbs = mbarr;
|
||||||
|
WCHAR wc;
|
||||||
|
|
||||||
|
if (mbchar == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (wchar == NULL)
|
if (wchar == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Status = RtlMultiByteToUnicodeN (wchar,
|
memcpy(mbarr, mbchar, min(count, sizeof mbarr));
|
||||||
sizeof(WCHAR),
|
|
||||||
&Size,
|
wc = RtlAnsiCharToUnicodeChar(&mbs);
|
||||||
mbchar,
|
|
||||||
count);
|
if (wc == L' ' && mbarr[0] != ' ')
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return (int)Size;
|
*wchar = wc;
|
||||||
|
|
||||||
|
return mbs - mbarr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue