Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenmbstowcs_nt.c
Go to the documentation of this file.
00001 #define WIN32_NO_STATUS 00002 #include <windows.h> 00003 #include <ndk/umtypes.h> 00004 #include <ndk/rtlfuncs.h> 00005 #include <string.h> 00006 00007 WCHAR NTAPI RtlAnsiCharToUnicodeChar(IN OUT PUCHAR *AnsiChar); 00008 #undef MB_CUR_MAX 00009 #define MB_CUR_MAX 2 00010 00011 /* 00012 * @implemented 00013 */ 00014 int mbtowc (wchar_t *wchar, const char *mbchar, size_t count) 00015 { 00016 UCHAR mbarr[MB_CUR_MAX] = { 0 }; 00017 PUCHAR mbs = mbarr; 00018 WCHAR wc; 00019 00020 if (mbchar == NULL) 00021 return 0; 00022 00023 if (wchar == NULL) 00024 return 0; 00025 00026 memcpy(mbarr, mbchar, min(count, sizeof mbarr)); 00027 00028 wc = RtlAnsiCharToUnicodeChar(&mbs); 00029 00030 if (wc == L' ' && mbarr[0] != ' ') 00031 return -1; 00032 00033 *wchar = wc; 00034 00035 return (int)(mbs - mbarr); 00036 } 00037 00038 /* 00039 * @implemented 00040 */ 00041 size_t mbstowcs (wchar_t *wcstr, const char *mbstr, size_t count) 00042 { 00043 NTSTATUS Status; 00044 ULONG Size; 00045 ULONG Length; 00046 00047 Length = (ULONG)strlen (mbstr); 00048 00049 if (wcstr == NULL) 00050 { 00051 RtlMultiByteToUnicodeSize (&Size, 00052 mbstr, 00053 Length); 00054 00055 return (size_t)Size; 00056 } 00057 00058 Status = RtlMultiByteToUnicodeN (wcstr, 00059 (ULONG)count * sizeof(WCHAR), 00060 &Size, 00061 mbstr, 00062 Length); 00063 if (!NT_SUCCESS(Status)) 00064 return -1; 00065 00066 return (size_t)Size; 00067 } 00068 00069 /* EOF */ Generated on Sat May 26 2012 04:35:35 for ReactOS by
1.7.6.1
|