1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 13:37:44 +00:00

LibC: Implement wcswidth

This commit is contained in:
Tim Schumacher 2022-06-29 05:01:14 +02:00 committed by Andreas Kling
parent 9497cc6c97
commit 6d4d6c3e2a
2 changed files with 18 additions and 0 deletions

View file

@ -531,6 +531,23 @@ int wcwidth(wchar_t wc)
return 1;
}
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/wcswidth.html
int wcswidth(wchar_t const* pwcs, size_t n)
{
int len = 0;
for (size_t i = 0; i < n && pwcs[i]; i++) {
int char_len = wcwidth(pwcs[i]);
if (char_len == -1)
return -1;
len += char_len;
}
return len;
}
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/wcsnrtombs.html
size_t wcsnrtombs(char* dest, wchar_t const** src, size_t nwc, size_t len, mbstate_t* ps)
{