mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:54:58 +00:00
LibC: Implement wcswidth
This commit is contained in:
parent
9497cc6c97
commit
6d4d6c3e2a
2 changed files with 18 additions and 0 deletions
|
@ -531,6 +531,23 @@ int wcwidth(wchar_t wc)
|
||||||
return 1;
|
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
|
// 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)
|
size_t wcsnrtombs(char* dest, wchar_t const** src, size_t nwc, size_t len, mbstate_t* ps)
|
||||||
{
|
{
|
||||||
|
|
|
@ -63,6 +63,7 @@ float wcstof(wchar_t const*, wchar_t**);
|
||||||
double wcstod(wchar_t const*, wchar_t**);
|
double wcstod(wchar_t const*, wchar_t**);
|
||||||
long double wcstold(wchar_t const*, wchar_t**);
|
long double wcstold(wchar_t const*, wchar_t**);
|
||||||
int wcwidth(wchar_t);
|
int wcwidth(wchar_t);
|
||||||
|
int wcswidth(wchar_t const*, size_t);
|
||||||
size_t wcsrtombs(char*, wchar_t const**, size_t, mbstate_t*);
|
size_t wcsrtombs(char*, wchar_t const**, size_t, mbstate_t*);
|
||||||
size_t mbsrtowcs(wchar_t*, char const**, size_t, mbstate_t*);
|
size_t mbsrtowcs(wchar_t*, char const**, size_t, mbstate_t*);
|
||||||
int wmemcmp(wchar_t const*, wchar_t const*, size_t);
|
int wmemcmp(wchar_t const*, wchar_t const*, size_t);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue