Added mbtowc(), mbstowcs(), wctomb() and wcstombs()

svn path=/trunk/; revision=914
This commit is contained in:
Eric Kohl 1999-12-30 14:39:43 +00:00
parent a8ca53d761
commit 974095c413
9 changed files with 205 additions and 20 deletions

View file

@ -1,4 +1,4 @@
; $Id: ntdll.def,v 1.34 1999/12/30 01:33:28 ekohl Exp $
; $Id: ntdll.def,v 1.35 1999/12/30 14:39:27 ekohl Exp $
;
; ReactOS Operating System
;
@ -595,7 +595,7 @@ iswctype
isxdigit
labs
log
;mbstowcs
mbstowcs
memchr
memcmp
memcpy
@ -643,7 +643,7 @@ wcsrchr
wcsspn
wcsstr
wcstol
;wcstombs
wcstombs
wcstoul
LdrGetExportByName
LdrGetExportByOrdinal

View file

@ -1,4 +1,4 @@
; $Id: ntdll.edf,v 1.24 1999/12/30 01:33:28 ekohl Exp $
; $Id: ntdll.edf,v 1.25 1999/12/30 14:39:27 ekohl Exp $
;
; ReactOS Operating System
;
@ -573,6 +573,7 @@ iswctype
isxdigit
labs
log
mbstowcs
memchr
memcmp
memcpy
@ -617,6 +618,7 @@ wcsrchr
wcsspn
wcsstr
wcstol
wcstombs
wcstoul
LdrGetExportByName
LdrGetExportByOrdinal

View file

@ -1,4 +1,4 @@
# $Id: makefile,v 1.32 1999/12/30 01:51:37 dwelch Exp $
# $Id: makefile,v 1.33 1999/12/30 14:39:43 ekohl Exp $
#
# ReactOS Operating System
#
@ -34,7 +34,8 @@ RTL_OBJECTS = rtl/critical.o rtl/error.o rtl/heap.o rtl/largeint.o \
STDLIB_OBJECTS = stdlib/abs.o stdlib/atoi.o stdlib/atoi64.o stdlib/atol.o \
stdlib/itoa.o stdlib/itow.o stdlib/labs.o stdlib/splitp.o \
stdlib/strtol.o stdlib/strtoul.o stdlib/wcstol.o \
stdlib/wcstoul.o stdlib/wtoi.o stdlib/wtoi64.o stdlib/wtol.o
stdlib/wcstoul.o stdlib/wtoi.o stdlib/wtoi64.o stdlib/wtol.o \
stdlib/mbstowcs.o stdlib/wcstombs.o
STRING_OBJECTS = string/ctype.o string/memccpy.o string/memchr.o \
string/memcmp.o string/memcpy.o string/memicmp.o\

View file

@ -0,0 +1,41 @@
/* $Id: mbstowcs.c,v 1.1 1999/12/30 14:38:54 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: lib/ntdll/stdlib/mbstowcs.c
* PURPOSE: converts a multi byte string to a unicode string
*/
#include <ddk/ntddk.h>
#include <stdlib.h>
#include <string.h>
size_t mbstowcs (wchar_t *wcstr, const char *mbstr, size_t count)
{
NTSTATUS Status;
ULONG Size;
ULONG Length;
Length = strlen (mbstr);
if (wcstr == NULL)
{
RtlMultiByteToUnicodeSize (&Size,
(char *)mbstr,
Length);
return (size_t)Size;
}
Status = RtlMultiByteToUnicodeN (wcstr,
count,
&Size,
(char *)mbstr,
Length);
if (!NT_SUCCESS(Status))
return -1;
return (size_t)Size;
}
/* EOF */

View file

@ -0,0 +1,41 @@
/* $Id: wcstombs.c,v 1.1 1999/12/30 14:38:54 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: lib/ntdll/stdlib/wcstombs.c
* PURPOSE: converts a unicode string to a multi byte string
*/
#include <ddk/ntddk.h>
#include <stdlib.h>
#include <string.h>
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 *)wcstr,
Length * sizeof(WCHAR));
return (size_t)Size;
}
Status = RtlUnicodeToMultiByteN (mbstr,
count,
&Size,
(wchar_t *)wcstr,
Length * sizeof(WCHAR));
if (!NT_SUCCESS(Status))
return -1;
return (size_t)Size;
}
/* EOF */

View file

@ -194,7 +194,6 @@ STUB(_fltused)
STUB(_snprintf)
STUB(_snwprintf)
STUB(_vsnprintf)
STUB(mbstowcs)
STUB(qsort)
STUB(sscanf)
STUB(swprintf)

View file

@ -1,4 +1,4 @@
; $Id: ntoskrnl.def,v 1.36 1999/12/29 01:36:34 ekohl Exp $
; $Id: ntoskrnl.def,v 1.37 1999/12/30 14:38:12 ekohl Exp $
;
; reactos/ntoskrnl/ntoskrnl.def
;
@ -408,8 +408,8 @@ isprint
isspace
isupper
isxdigit
;mbstowcs
;mbtowc
mbstowcs
mbtowc
memchr
memcpy
memmove
@ -429,7 +429,6 @@ strcpy
strrchr
strspn
strstr
;strtok
;swprintf
tolower
toupper
@ -448,8 +447,8 @@ wcsncpy
wcsrchr
wcsspn
wcsstr
;wcstombs
;wctomb
wcstombs
wctomb
;
;
; exports from hal.dll

View file

@ -1,4 +1,4 @@
; $Id: ntoskrnl.edf,v 1.23 1999/12/29 01:36:34 ekohl Exp $
; $Id: ntoskrnl.edf,v 1.24 1999/12/30 14:38:12 ekohl Exp $
;
; reactos/ntoskrnl/ntoskrnl.def
;
@ -406,8 +406,8 @@ isprint
isspace
isupper
isxdigit
;mbstowcs
;mbtowc
mbstowcs
mbtowc
memchr
memcpy
memmove
@ -427,7 +427,6 @@ strcpy
strrchr
strspn
strstr
;strtok
;swprintf
tolower
toupper
@ -446,8 +445,8 @@ wcsncpy
wcsrchr
wcsspn
wcsstr
;wcstombs
;wctomb
wcstombs
wctomb
;
;
; exports from hal.dll

View file

@ -1,4 +1,5 @@
/*
/* $Id: stdlib.c,v 1.4 1999/12/30 14:37:54 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/rtl/stdlib.c
@ -10,9 +11,11 @@
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
#include <ctype.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
/* GLOBALS ****************************************************************/
@ -154,3 +157,103 @@ void srand(unsigned seed)
{
next = seed;
}
int mbtowc (wchar_t *wchar, const char *mbchar, size_t count)
{
NTSTATUS Status;
ULONG Size;
if (wchar == NULL)
return 0;
Status = RtlMultiByteToUnicodeN (wchar,
sizeof(WCHAR),
&Size,
(char *)mbchar,
count);
if (!NT_SUCCESS(Status))
return -1;
return (int)Size;
}
size_t mbstowcs (wchar_t *wcstr, const char *mbstr, size_t count)
{
NTSTATUS Status;
ULONG Size;
ULONG Length;
Length = strlen (mbstr);
if (wcstr == NULL)
{
RtlMultiByteToUnicodeSize (&Size,
(char *)mbstr,
Length);
return (size_t)Size;
}
Status = RtlMultiByteToUnicodeN (wcstr,
count,
&Size,
(char *)mbstr,
Length);
if (!NT_SUCCESS(Status))
return -1;
return (size_t)Size;
}
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;
}
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 *)wcstr,
Length * sizeof(WCHAR));
return (size_t)Size;
}
Status = RtlUnicodeToMultiByteN (mbstr,
count,
&Size,
(wchar_t *)wcstr,
Length * sizeof(WCHAR));
if (!NT_SUCCESS(Status))
return -1;
return (size_t)Size;
}
/* EOF */