int wcswidth_l(const wchar_t *pwcs, size_t n, locale_t locale) { wchar_t wc; int len, l; FIX_LOCALE(locale); len = 0; while (n-- > 0 && (wc = *pwcs++) != L'\0') { if ((l = wcwidth_l(wc, locale)) < 0) return (-1); len += l; } return (len); }
int wcswidth_l(const wchar_t *s, size_t n, locale_t locale) { int w, q; FIX_LOCALE(locale); w = 0; while (n && *s) { q = wcwidth_l(*s, locale); if (q == -1) return (-1); w += q; s++; n--; } return w; }