mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-21 09:49:21 +00:00
LibC: Add some wchar functions
These are basically copy and pasted from the regular string version. Also add some more multi-byte/wide conversion stub. libarchive wanted these. There's a lot more, but we can add them one at a time.
This commit is contained in:
parent
92953ba2f3
commit
ef40ebbe6d
Notes:
sideshowbarker
2024-07-19 11:43:05 +09:00
Author: https://github.com/NattyNarwhal
Commit: ef40ebbe6d
Pull-request: https://github.com/SerenityOS/serenity/pull/651
5 changed files with 59 additions and 1 deletions
40
Libraries/LibC/wchar.cpp
Normal file
40
Libraries/LibC/wchar.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
#include <wchar.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
size_t wcslen(const wchar_t* str)
|
||||
{
|
||||
size_t len = 0;
|
||||
while (*(str++))
|
||||
++len;
|
||||
return len;
|
||||
}
|
||||
|
||||
wchar_t* wcscpy(wchar_t* dest, const wchar_t* src)
|
||||
{
|
||||
wchar_t* originalDest = dest;
|
||||
while ((*dest++ = *src++) != '\0')
|
||||
;
|
||||
return originalDest;
|
||||
}
|
||||
|
||||
int wcscmp(const wchar_t* s1, const wchar_t* s2)
|
||||
{
|
||||
while (*s1 == *s2++)
|
||||
if (*s1++ == 0)
|
||||
return 0;
|
||||
return *(const wchar_t*)s1 - *(const wchar_t*)--s2;
|
||||
}
|
||||
|
||||
wchar_t* wcschr(const wchar_t* str, int c)
|
||||
{
|
||||
wchar_t ch = c;
|
||||
for (;; ++str) {
|
||||
if (*str == ch)
|
||||
return const_cast<wchar_t*>(str);
|
||||
if (!*str)
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue