3 <<wcswidth>>---number of column positions of a wide-character string
10 int wcswidth(const wchar_t *<[pwcs]>, size_t <[n]>);
13 The <<wcswidth>> function shall determine the number of column
14 positions required for <[n]> wide-character codes (or fewer than <[n]>
15 wide-character codes if a null wide-character code is encountered
16 before <[n]> wide-character codes are exhausted) in the string pointed
20 The <<wcswidth>> function either shall return 0 (if <[pwcs]> points to a
21 null wide-character code), or return the number of column positions
22 to be occupied by the wide-character string pointed to by <[pwcs]>, or
23 return -1 (if any of the first <[n]> wide-character codes in the
24 wide-character string pointed to by <[pwcs]> is not a printable
28 <<wcswidth>> has been introduced in the Single UNIX Specification Volume 2.
29 <<wcswidth>> has been marked as an extension in the Single UNIX Specification Volume 3.
37 wcswidth (const wchar_t *pwcs
,
49 /* First half of a surrogate pair? */
50 if (sizeof (wchar_t) == 2 && wi
>= 0xd800 && wi
<= 0xdbff)
54 /* Extract second half and check for validity. */
55 if (--n
== 0 || (wi2
= _jp2uc (*++pwcs
)) < 0xdc00 || wi2
> 0xdfff)
57 /* Compute actual unicode value to use in call to __wcwidth. */
58 wi
= (((wi
& 0x3ff) << 10) | (wi2
& 0x3ff)) + 0x10000;
60 #endif /* _MB_CAPABLE */
61 if ((w
= __wcwidth (wi
)) < 0)
64 } while (*pwcs
++ && --n
> 0);