Add SDK/CRT string routines and headers
This commit is contained in:
45
SDK/CRT/STRING/wstr.c
Normal file
45
SDK/CRT/STRING/wstr.c
Normal file
@@ -0,0 +1,45 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2024, Quinn Stephens.
|
||||
Provided under the BSD 3-Clause license.
|
||||
|
||||
Module Name:
|
||||
|
||||
wstr.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Provides wide string manipulation routines.
|
||||
|
||||
--*/
|
||||
|
||||
#include <wchar.h>
|
||||
|
||||
size_t
|
||||
wcslen (
|
||||
const wchar_t *str
|
||||
)
|
||||
|
||||
{
|
||||
const wchar_t *ptr;
|
||||
|
||||
ptr = str;
|
||||
while (*ptr++);
|
||||
|
||||
return (const char*)ptr - (const char*)str - sizeof(wchar_t);
|
||||
}
|
||||
|
||||
size_t
|
||||
wcsnlen (
|
||||
const wchar_t *str,
|
||||
size_t maxlen
|
||||
)
|
||||
|
||||
{
|
||||
size_t len;
|
||||
|
||||
len = 0;
|
||||
while (len < maxlen && str[len++]);
|
||||
|
||||
return len - sizeof(wchar_t);
|
||||
}
|
Reference in New Issue
Block a user