mirror of
https://github.com/reactos/reactos.git
synced 2024-11-11 01:04:11 +00:00
c424146e2c
svn path=/branches/cmake-bringup/; revision=48236
59 lines
1.2 KiB
C
59 lines
1.2 KiB
C
#define WIN32_NO_STATUS
|
|
#include <windows.h>
|
|
#include <ndk/umtypes.h>
|
|
#include <ndk/rtlfuncs.h>
|
|
|
|
/*
|
|
* @implemented
|
|
*/
|
|
int wctomb (char *mbchar, wchar_t wchar)
|
|
{
|
|
NTSTATUS Status;
|
|
ULONG Size;
|
|
|
|
if (mbchar == NULL)
|
|
return 0;
|
|
|
|
Status = RtlUnicodeToMultiByteN (mbchar,
|
|
1,
|
|
&Size,
|
|
&wchar,
|
|
sizeof(WCHAR));
|
|
if (!NT_SUCCESS(Status))
|
|
return -1;
|
|
|
|
return (int)Size;
|
|
}
|
|
|
|
/*
|
|
* @implemented
|
|
*/
|
|
size_t wcstombs (char *mbstr, const wchar_t *wcstr, size_t count)
|
|
{
|
|
NTSTATUS Status;
|
|
ULONG Size;
|
|
ULONG Length;
|
|
|
|
Length = wcslen (wcstr);
|
|
|
|
if (mbstr == NULL)
|
|
{
|
|
RtlUnicodeToMultiByteSize (&Size,
|
|
(wchar_t*)((size_t)wcstr),
|
|
Length * sizeof(WCHAR));
|
|
|
|
return (size_t)Size;
|
|
}
|
|
|
|
Status = RtlUnicodeToMultiByteN (mbstr,
|
|
count,
|
|
&Size,
|
|
(wchar_t*)((size_t)wcstr),
|
|
Length * sizeof(WCHAR));
|
|
if (!NT_SUCCESS(Status))
|
|
return -1;
|
|
|
|
return (size_t)Size;
|
|
}
|
|
|
|
/* EOF */
|