:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[reactos.git] / lib / ntdll / stdlib / mbstowcs.c
1 /* $Id$
2  *
3  * COPYRIGHT:       See COPYING in the top level directory
4  * PROJECT:         ReactOS kernel
5  * FILE:            lib/ntdll/stdlib/mbstowcs.c
6  * PURPOSE:         converts a multi byte string to a unicode string
7  */
8
9 #include <ddk/ntddk.h>
10 #include <stdlib.h>
11 #include <string.h>
12
13 size_t mbstowcs (wchar_t *wcstr, const char *mbstr, size_t count)
14 {
15         NTSTATUS Status;
16         ULONG Size;
17         ULONG Length;
18
19         Length = strlen (mbstr);
20
21         if (wcstr == NULL)
22         {
23                 RtlMultiByteToUnicodeSize (&Size,
24                                            (char *)mbstr,
25                                            Length);
26
27                 return (size_t)Size;
28         }
29
30         Status = RtlMultiByteToUnicodeN (wcstr,
31                                          count,
32                                          &Size,
33                                          (char *)mbstr,
34                                          Length);
35         if (!NT_SUCCESS(Status))
36                 return -1;
37
38         return (size_t)Size;
39 }
40
41 /* EOF */