e2f2a6af6125ba8d7f378a9d6b5a43c08629bcfb
2 * PROJECT: ReactOS CRT library
3 * LICENSE: LGPL - See COPYING in the top level directory
4 * FILE: lib/sdk/crt/string/wcs.c
5 * PURPOSE: wcs* CRT functions
6 * PROGRAMMERS: Wine team
7 * Ported to ReactOS by Aleksey Bragin (aleksey@reactos.org)
11 * msvcrt.dll wide-char functions
13 * Copyright 1999 Alexandre Julliard
14 * Copyright 2000 Jon Griffiths
16 * This library is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU Lesser General Public
18 * License as published by the Free Software Foundation; either
19 * version 2.1 of the License, or (at your option) any later version.
21 * This library is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * Lesser General Public License for more details.
26 * You should have received a copy of the GNU Lesser General Public
27 * License along with this library; if not, write to the Free Software
28 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
34 #include <internal/wine/msvcrt.h>
37 #include "wine/unicode.h"
38 //#include "wine/debug.h"
41 //WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
51 #pragma function(_wcsset)
55 /*********************************************************************
58 wchar_t* CDECL
_wcsdup( const wchar_t* str
)
63 int size
= (strlenW(str
) + 1) * sizeof(wchar_t);
65 if (ret
) memcpy( ret
, str
, size
);
69 /*********************************************************************
70 * _wcsicoll (MSVCRT.@)
72 INT CDECL
_wcsicoll( const wchar_t* str1
, const wchar_t* str2
)
74 /* FIXME: handle collates */
75 return strcmpiW( str1
, str2
);
79 /*********************************************************************
82 wchar_t* CDECL
_wcsnset( wchar_t* str
, wchar_t c
, size_t n
)
85 while ((n
-- > 0) && *str
) *str
++ = c
;
89 /*********************************************************************
92 wchar_t* CDECL
_wcsrev( wchar_t* str
)
95 wchar_t* end
= str
+ strlenW(str
) - 1;
106 /*********************************************************************
109 wchar_t* CDECL
_wcsset( wchar_t* str
, wchar_t c
)
112 while (*str
) *str
++ = c
;
116 /******************************************************************
117 * _wcsupr_s (MSVCRT.@)
120 INT CDECL
_wcsupr_s( wchar_t* str
, size_t n
)
126 if (str
) *str
= '\0';
134 *ptr
= toupperW(*ptr
);
138 /* MSDN claims that the function should return and set errno to
139 * ERANGE, which doesn't seem to be true based on the tests. */
145 /*********************************************************************
148 double CDECL
wcstod(const wchar_t* lpszStr
, wchar_t** end
)
150 const wchar_t* str
= lpszStr
;
152 double ret
= 0, divisor
= 10.0;
154 TRACE("(%s,%p) semi-stub\n", debugstr_w(lpszStr
), end
);
157 * - Should set errno on failure
158 * - Should fail on overflow
159 * - Need to check which input formats are allowed
161 while (isspaceW(*str
))
170 while (isdigitW(*str
))
172 ret
= ret
* 10.0 + (*str
- '0');
177 while (isdigitW(*str
))
179 ret
= ret
+ (*str
- '0') / divisor
;
184 if (*str
== 'E' || *str
== 'e' || *str
== 'D' || *str
== 'd')
186 int negativeExponent
= 0;
190 negativeExponent
= 1;
193 while (isdigitW(*str
))
195 exponent
= exponent
* 10 + (*str
- '0');
200 if (negativeExponent
)
201 ret
= ret
/ pow(10.0, exponent
);
203 ret
= ret
* pow(10.0, exponent
);
211 *end
= (wchar_t*)str
;
213 TRACE("returning %g\n", ret
);
217 typedef struct pf_output_t
228 typedef struct pf_flags_t
230 char Sign
, LeftAlign
, Alternate
, PadZero
;
231 int FieldLength
, Precision
;
232 char IntegerLength
, IntegerDouble
;
238 * writes a string of characters to the output
239 * returns -1 if the string doesn't fit in the output buffer
240 * return the length of the string if all characters were written
242 static inline int pf_output_stringW( pf_output
*out
, LPCWSTR str
, int len
)
244 int space
= out
->len
- out
->used
;
247 len
= strlenW( str
);
250 LPWSTR p
= out
->buf
.W
+ out
->used
;
254 memcpy( p
, str
, len
*sizeof(WCHAR
) );
259 memcpy( p
, str
, space
*sizeof(WCHAR
) );
264 int n
= WideCharToMultiByte( CP_ACP
, 0, str
, len
, NULL
, 0, NULL
, NULL
);
265 LPSTR p
= out
->buf
.A
+ out
->used
;
269 WideCharToMultiByte( CP_ACP
, 0, str
, len
, p
, n
, NULL
, NULL
);
274 WideCharToMultiByte( CP_ACP
, 0, str
, len
, p
, space
, NULL
, NULL
);
280 static inline int pf_output_stringA( pf_output
*out
, LPCSTR str
, int len
)
282 int space
= out
->len
- out
->used
;
288 LPSTR p
= out
->buf
.A
+ out
->used
;
292 memcpy( p
, str
, len
);
297 memcpy( p
, str
, space
);
302 int n
= MultiByteToWideChar( CP_ACP
, 0, str
, len
, NULL
, 0 );
303 LPWSTR p
= out
->buf
.W
+ out
->used
;
307 MultiByteToWideChar( CP_ACP
, 0, str
, len
, p
, n
);
312 MultiByteToWideChar( CP_ACP
, 0, str
, len
, p
, space
);
318 /* pf_fill: takes care of signs, alignment, zero and field padding */
319 static inline int pf_fill( pf_output
*out
, int len
, pf_flags
*flags
, char left
)
323 if( flags
->Sign
&& !( flags
->Format
== 'd' || flags
->Format
== 'i' ) )
326 if( left
&& flags
->Sign
)
328 flags
->FieldLength
--;
330 r
= pf_output_stringA( out
, &flags
->Sign
, 1 );
333 if( ( !left
&& flags
->LeftAlign
) ||
334 ( left
&& !flags
->LeftAlign
))
336 for( i
=0; (i
<(flags
->FieldLength
-len
)) && (r
>=0); i
++ )
338 if( left
&& flags
->PadZero
)
339 r
= pf_output_stringA( out
, "0", 1 );
341 r
= pf_output_stringA( out
, " ", 1 );
345 if( left
&& flags
->Sign
&& !flags
->PadZero
)
346 r
= pf_output_stringA( out
, &flags
->Sign
, 1 );
351 static inline int pf_output_format_W( pf_output
*out
, LPCWSTR str
,
352 int len
, pf_flags
*flags
)
357 len
= strlenW( str
);
359 if (flags
->Precision
>= 0 && flags
->Precision
< len
)
360 len
= flags
->Precision
;
362 r
= pf_fill( out
, len
, flags
, 1 );
365 r
= pf_output_stringW( out
, str
, len
);
368 r
= pf_fill( out
, len
, flags
, 0 );
373 static inline int pf_output_format_A( pf_output
*out
, LPCSTR str
,
374 int len
, pf_flags
*flags
)
381 if (flags
->Precision
>= 0 && flags
->Precision
< len
)
382 len
= flags
->Precision
;
384 r
= pf_fill( out
, len
, flags
, 1 );
387 r
= pf_output_stringA( out
, str
, len
);
390 r
= pf_fill( out
, len
, flags
, 0 );
395 #ifndef USE_NEW_SPRINTF
396 static int pf_handle_string_format( pf_output
*out
, const void* str
, int len
,
397 pf_flags
*flags
, BOOL capital_letter
)
399 if(str
== NULL
) /* catch NULL pointer */
400 return pf_output_format_A( out
, "(null)", -1, flags
);
402 /* prefixes take priority over %c,%s vs. %C,%S, so we handle them first */
403 if(flags
->WideString
|| flags
->IntegerLength
== 'l')
404 return pf_output_format_W( out
, str
, len
, flags
);
405 if(flags
->IntegerLength
== 'h')
406 return pf_output_format_A( out
, str
, len
, flags
);
408 /* %s,%c -> chars in ansi functions & wchars in unicode
409 * %S,%C -> wchars in ansi functions & chars in unicode */
410 if( capital_letter
== out
->unicode
) /* either both TRUE or both FALSE */
411 return pf_output_format_A( out
, str
, len
, flags
);
413 return pf_output_format_W( out
, str
, len
, flags
);
416 static inline BOOL
pf_is_integer_format( char fmt
)
418 static const char float_fmts
[] = "diouxX";
421 return strchr( float_fmts
, fmt
) ? TRUE
: FALSE
;
424 static inline BOOL
pf_is_double_format( char fmt
)
426 static const char float_fmts
[] = "aeEfgG";
429 return strchr( float_fmts
, fmt
) ? TRUE
: FALSE
;
432 static inline BOOL
pf_is_valid_format( char fmt
)
434 static const char float_fmts
[] = "acCdeEfgGinouxX";
437 return strchr( float_fmts
, fmt
) ? TRUE
: FALSE
;
440 static void pf_rebuild_format_string( char *p
, pf_flags
*flags
)
445 if( flags
->LeftAlign
)
446 *p
++ = flags
->LeftAlign
;
447 if( flags
->Alternate
)
448 *p
++ = flags
->Alternate
;
450 *p
++ = flags
->PadZero
;
451 if( flags
->FieldLength
)
453 lnx_sprintf(p
, "%d", flags
->FieldLength
);
456 if( flags
->Precision
>= 0 )
458 lnx_sprintf(p
, ".%d", flags
->Precision
);
461 *p
++ = flags
->Format
;
465 /* pf_integer_conv: prints x to buf, including alternate formats and
466 additional precision digits, but not field characters or the sign */
467 static void pf_integer_conv( char *buf
, unsigned int buf_len
, pf_flags
*flags
,
474 char number
[40], *tmp
= number
;
476 if( buf_len
> sizeof number
)
477 tmp
= HeapAlloc( GetProcessHeap(), 0, buf_len
);
480 if( flags
->Format
== 'o' )
482 else if( flags
->Format
== 'x' || flags
->Format
== 'X' )
485 if( flags
->Format
== 'X' )
486 digits
= "0123456789ABCDEFX";
488 digits
= "0123456789abcdefx";
490 if( x
< 0 && ( flags
->Format
== 'd' || flags
->Format
== 'i' ) )
496 /* Do conversion (backwards) */
498 if( x
== 0 && flags
->Precision
)
503 j
= (ULONGLONG
) x
% base
;
504 x
= (ULONGLONG
) x
/ base
;
505 tmp
[i
++] = digits
[j
];
507 k
= flags
->Precision
- i
;
510 if( flags
->Alternate
)
514 tmp
[i
++] = digits
[16];
517 else if( base
== 8 && tmp
[i
-1] != '0' )
521 /* Reverse for buf */
527 /* Adjust precision so pf_fill won't truncate the number later */
528 flags
->Precision
= strlen( buf
);
531 HeapFree( GetProcessHeap(), 0, tmp
);
536 /*********************************************************************
537 * pf_vsnprintf (INTERNAL)
539 * implements both A and W vsnprintf functions
541 static int pf_vsnprintf( pf_output
*out
, const WCHAR
*format
, va_list valist
)
544 LPCWSTR q
, p
= format
;
547 TRACE("format is %s\n",debugstr_w(format
));
550 q
= strchrW( p
, '%' );
552 /* there's no % characters left, output the rest of the string */
555 r
= pf_output_stringW(out
, p
, -1);
562 /* there's characters before the %, output them */
565 r
= pf_output_stringW(out
, p
, q
- p
);
571 /* we must be at a % now, skip over it */
575 /* output a single % character */
578 r
= pf_output_stringW(out
, p
++, 1);
584 /* parse the flags */
585 memset( &flags
, 0, sizeof flags
);
588 if( *p
== '+' || *p
== ' ' )
590 if ( flags
.Sign
!= '+' )
594 flags
.LeftAlign
= *p
;
598 flags
.Alternate
= *p
;
604 /* deal with the field width specifier */
605 flags
.FieldLength
= 0;
608 flags
.FieldLength
= va_arg( valist
, int );
609 if (flags
.FieldLength
< 0)
611 flags
.LeftAlign
= '-';
612 flags
.FieldLength
= -flags
.FieldLength
;
616 else while( isdigit(*p
) )
618 flags
.FieldLength
*= 10;
619 flags
.FieldLength
+= *p
++ - '0';
622 /* deal with precision */
623 flags
.Precision
= -1;
630 flags
.Precision
= va_arg( valist
, int );
633 else while( isdigit(*p
) )
635 flags
.Precision
*= 10;
636 flags
.Precision
+= *p
++ - '0';
640 /* deal with integer width modifier */
643 if( *p
== 'h' || *p
== 'l' || *p
== 'L' )
645 flags
.IntegerLength
= *p
;
650 if( *(p
+1) == '6' && *(p
+2) == '4' )
652 flags
.IntegerDouble
++;
655 else if( *(p
+1) == '3' && *(p
+2) == '2' )
657 else if( isdigit(*(p
+1)) || *(p
+1) == 0 )
663 flags
.WideString
= *p
++;
673 /* output a string */
674 if( flags
.Format
== 's' || flags
.Format
== 'S' )
675 r
= pf_handle_string_format( out
, va_arg(valist
, const void*), -1,
676 &flags
, (flags
.Format
== 'S') );
678 /* output a single character */
679 else if( flags
.Format
== 'c' || flags
.Format
== 'C' )
681 INT ch
= va_arg( valist
, int );
683 r
= pf_handle_string_format( out
, &ch
, 1, &flags
, (flags
.Format
== 'C') );
686 /* output a pointer */
687 else if( flags
.Format
== 'p' )
692 if( flags
.Alternate
)
693 lnx_sprintf(pointer
, "0X%08lX", va_arg(valist
, long));
695 lnx_sprintf(pointer
, "%08lX", va_arg(valist
, long));
696 r
= pf_output_format_A( out
, pointer
, -1, &flags
);
700 else if( flags
.Format
== 'n' )
702 int *x
= va_arg(valist
, int *);
706 /* deal with 64-bit integers */
707 else if( pf_is_integer_format( flags
.Format
) && flags
.IntegerDouble
)
709 char number
[40], *x
= number
;
711 /* Estimate largest possible required buffer size:
712 * Chooses the larger of the field or precision
713 * Includes extra bytes: 1 byte for null, 1 byte for sign,
714 4 bytes for exponent, 2 bytes for alternate formats, 1 byte
715 for a decimal, and 1 byte for an additional float digit. */
716 unsigned x_len
= ((flags
.FieldLength
> flags
.Precision
) ?
717 flags
.FieldLength
: flags
.Precision
) + 10;
719 if( x_len
>= sizeof number
)
720 x
= HeapAlloc( GetProcessHeap(), 0, x_len
);
722 pf_integer_conv( x
, x_len
, &flags
, va_arg(valist
, LONGLONG
) );
724 r
= pf_output_format_A( out
, x
, -1, &flags
);
726 HeapFree( GetProcessHeap(), 0, x
);
729 /* deal with integers and floats using libc's printf */
730 else if( pf_is_valid_format( flags
.Format
) )
732 char fmt
[20], number
[40], *x
= number
;
734 /* Estimate largest possible required buffer size:
735 * Chooses the larger of the field or precision
736 * Includes extra bytes: 1 byte for null, 1 byte for sign,
737 4 bytes for exponent, 2 bytes for alternate formats, 1 byte
738 for a decimal, and 1 byte for an additional float digit. */
739 unsigned x_len
= ((flags
.FieldLength
> flags
.Precision
) ?
740 flags
.FieldLength
: flags
.Precision
) + 10;
742 if( x_len
>= sizeof number
)
743 x
= HeapAlloc( GetProcessHeap(), 0, x_len
);
745 pf_rebuild_format_string( fmt
, &flags
);
747 if( pf_is_double_format( flags
.Format
) )
748 lnx_sprintf( x
, fmt
, va_arg(valist
, double) );
750 lnx_sprintf( x
, fmt
, va_arg(valist
, int) );
752 r
= pf_output_stringA( out
, x
, -1 );
754 HeapFree( GetProcessHeap(), 0, x
);
764 /* check we reached the end, and null terminate the string */
766 pf_output_stringW( out
, p
, 1 );
768 return out
->used
- 1;
771 /*********************************************************************
772 * _vsnprintf (MSVCRT.@)
774 int CDECL
_vsnprintf( char *str
, size_t len
,
775 const char *format
, va_list valist
)
778 LPWSTR formatW
= NULL
;
789 sz
= MultiByteToWideChar( CP_ACP
, 0, format
, -1, NULL
, 0 );
790 formatW
= HeapAlloc( GetProcessHeap(), 0, sz
*sizeof(WCHAR
) );
791 MultiByteToWideChar( CP_ACP
, 0, format
, -1, formatW
, sz
);
794 r
= pf_vsnprintf( &out
, formatW
, valist
);
796 HeapFree( GetProcessHeap(), 0, formatW
);
801 /*********************************************************************
802 * vsprintf (MSVCRT.@)
804 int CDECL
vsprintf( char *str
, const char *format
, va_list valist
)
806 return _vsnprintf(str
, INT_MAX
, format
, valist
);
809 /*********************************************************************
810 * _snprintf (MSVCRT.@)
812 int CDECL
_snprintf(char *str
, size_t len
, const char *format
, ...)
816 va_start(valist
, format
);
817 retval
= _vsnprintf(str
, len
, format
, valist
);
822 /*********************************************************************
823 * _vsnwsprintf (MSVCRT.@)
825 int CDECL
_vsnwprintf( wchar_t *str
, size_t len
,
826 const wchar_t *format
, va_list valist
)
835 return pf_vsnprintf( &out
, format
, valist
);
838 /*********************************************************************
839 * _snwprintf (MSVCRT.@)
841 int CDECL
_snwprintf( wchar_t *str
, size_t len
, const wchar_t *format
, ...)
845 va_start(valist
, format
);
846 retval
= _vsnwprintf(str
, len
, format
, valist
);
851 /*********************************************************************
854 int CDECL
sprintf( char *str
, const char *format
, ... )
859 va_start( ap
, format
);
860 r
= _vsnprintf( str
, INT_MAX
, format
, ap
);
865 /*********************************************************************
866 * swprintf (MSVCRT.@)
868 int CDECL
swprintf( wchar_t *str
, const wchar_t *format
, ... )
873 va_start( ap
, format
);
874 r
= _vsnwprintf( str
, INT_MAX
, format
, ap
);
879 /*********************************************************************
880 * vswprintf (MSVCRT.@)
882 int CDECL
vswprintf( wchar_t* str
, const wchar_t* format
, va_list args
)
884 return _vsnwprintf( str
, INT_MAX
, format
, args
);
889 /*********************************************************************
892 int CDECL
wcscoll( const wchar_t* str1
, const wchar_t* str2
)
894 /* FIXME: handle collates */
895 return strcmpW( str1
, str2
);
898 /*********************************************************************
901 wchar_t* CDECL
wcspbrk( const wchar_t* str
, const wchar_t* accept
)
906 for (p
= accept
; *p
; p
++) if (*p
== *str
) return (wchar_t*)str
;
913 /*********************************************************************
916 wchar_t * CDECL
wcstok( wchar_t *str
, const wchar_t *delim
)
918 MSVCRT_thread_data
*data
= msvcrt_get_thread_data();
922 if (!(str
= data
->wcstok_next
)) return NULL
;
924 while (*str
&& strchrW( delim
, *str
)) str
++;
925 if (!*str
) return NULL
;
927 while (*str
&& !strchrW( delim
, *str
)) str
++;
928 if (*str
) *str
++ = 0;
929 data
->wcstok_next
= str
;
933 /*********************************************************************
936 INT CDECL
wctomb(char *mbchar
, wchar_t wchar
)
938 BOOL bUsedDefaultChar
;
939 char chMultiByte
[MB_LEN_MAX
];
942 /* At least one parameter needs to be given, the length of a null character cannot be queried (verified by tests under WinXP SP2) */
943 if(!mbchar
&& !wchar
)
946 /* Use WideCharToMultiByte for doing the conversion using the codepage currently set with setlocale() */
947 nBytes
= WideCharToMultiByte(MSVCRT___lc_codepage
, 0, &wchar
, 1, chMultiByte
, MB_LEN_MAX
, NULL
, &bUsedDefaultChar
);
949 /* Only copy the character if an 'mbchar' pointer was given.
951 The "C" locale is emulated with codepage 1252 here. This codepage has a default character "?", but the "C" locale doesn't have one.
952 Therefore don't copy the character in this case. */
953 if(mbchar
&& !(MSVCRT_current_lc_all
[0] == 'C' && !MSVCRT_current_lc_all
[1] && bUsedDefaultChar
))
954 memcpy(mbchar
, chMultiByte
, nBytes
);
956 /* If the default character was used, set errno to EILSEQ and return -1. */
963 /* Otherwise return the number of bytes this character occupies. */
967 size_t CDECL
wcstombs(char *mbstr
, const wchar_t *wcstr
, size_t count
)
969 BOOL bUsedDefaultChar
;
973 /* Does the caller query for output buffer size? */
978 /* If we currently use the "C" locale, the length of the input string is returned (verified by tests under WinXP SP2) */
979 if(MSVCRT_current_lc_all
[0] == 'C' && !MSVCRT_current_lc_all
[1])
980 return wcslen(wcstr
);
982 /* Otherwise check the length each character needs and build a final return value out of this */
983 count
= wcslen(wcstr
);
986 while((int)(--count
) >= 0 && *wcstr
)
988 /* Get the length of this character */
989 nResult
= wctomb(NULL
, *wcstr
++);
991 /* If this character is not convertible in the current locale, the end result will be -1 */
998 /* Return the final length */
1002 /* Convert the string then */
1003 bUsedDefaultChar
= FALSE
;
1007 char chMultiByte
[MB_LEN_MAX
];
1010 /* Are we at the terminating null character? */
1013 /* Set the null character, but don't increment the pointer as the returned length never includes the terminating null character */
1018 /* Convert this character into the temporary chMultiByte variable */
1019 ZeroMemory(chMultiByte
, MB_LEN_MAX
);
1020 nResult
= wctomb(chMultiByte
, *wcstr
++);
1022 /* Check if this was an invalid character */
1024 bUsedDefaultChar
= TRUE
;
1026 /* If we got no character, stop the conversion process here */
1030 /* Determine whether this is a double-byte or a single-byte character */
1036 /* Decrease 'count' by the character length and check if the buffer can still hold the full character */
1042 /* It can, so copy it and move the pointer forward */
1043 memcpy(p
, chMultiByte
, uLength
);
1047 if(bUsedDefaultChar
)
1050 /* Return the length in bytes of the copied characters (without the terminating null character) */
1056 /*********************************************************************
1057 * iswalnum (MSVCRT.@)
1059 INT CDECL
iswalnum( wchar_t wc
)
1061 return isalnumW( wc
);
1064 /*********************************************************************
1065 * iswalpha (MSVCRT.@)
1067 INT CDECL
iswalpha( wchar_t wc
)
1069 return isalphaW( wc
);
1072 /*********************************************************************
1073 * iswcntrl (MSVCRT.@)
1075 INT CDECL
iswcntrl( wchar_t wc
)
1077 return iscntrlW( wc
);
1080 /*********************************************************************
1081 * iswdigit (MSVCRT.@)
1083 INT CDECL
iswdigit( wchar_t wc
)
1085 return isdigitW( wc
);
1088 /*********************************************************************
1089 * iswgraph (MSVCRT.@)
1091 INT CDECL
iswgraph( wchar_t wc
)
1093 return isgraphW( wc
);
1096 /*********************************************************************
1097 * iswlower (MSVCRT.@)
1099 INT CDECL
iswlower( wchar_t wc
)
1101 return islowerW( wc
);
1104 /*********************************************************************
1105 * iswprint (MSVCRT.@)
1107 INT CDECL
iswprint( wchar_t wc
)
1109 return isprintW( wc
);
1112 /*********************************************************************
1113 * iswpunct (MSVCRT.@)
1115 INT CDECL
iswpunct( wchar_t wc
)
1117 return ispunctW( wc
);
1120 /*********************************************************************
1121 * iswspace (MSVCRT.@)
1123 INT CDECL
iswspace( wchar_t wc
)
1125 return isspaceW( wc
);
1128 /*********************************************************************
1129 * iswupper (MSVCRT.@)
1131 INT CDECL
iswupper( wchar_t wc
)
1133 return isupperW( wc
);
1136 /*********************************************************************
1137 * iswxdigit (MSVCRT.@)
1139 INT CDECL
iswxdigit( wchar_t wc
)
1141 return isxdigitW( wc
);
1146 /*********************************************************************
1147 * wcscpy_s (MSVCRT.@)
1149 INT CDECL
wcscpy_s( wchar_t* wcDest
, size_t numElement
, const wchar_t *wcSrc
)
1153 if(!wcDest
|| !numElement
)
1163 size
= strlenW(wcSrc
) + 1;
1165 if(size
> numElement
)
1170 memcpy( wcDest
, wcSrc
, size
*sizeof(WCHAR
) );
1175 /******************************************************************
1176 * wcsncpy_s (MSVCRT.@)
1178 INT CDECL
wcsncpy_s( wchar_t* wcDest
, size_t numElement
, const wchar_t *wcSrc
,
1183 if (!wcDest
|| !numElement
)
1193 size
= min(strlenW(wcSrc
), count
);
1195 if (size
>= numElement
)
1200 memcpy( wcDest
, wcSrc
, size
*sizeof(WCHAR
) );
1201 wcDest
[size
] = '\0';