WCSWIDTH(3POSIX)

πŸ’– WCSWIDTH(3POSIX) πŸ’–

okay bestie so this one is part of the POSIX Programmer's Manual β€” you know, the group chat where all the Unix standards hang out. ✨

heads up tho: the Linux version of this interface might lowkey be different from what's written here (so go check the Linux man page for the deets on Linux behavior), or honestly it might not even be implemented on Linux at all. 😭 vibe check your platform first, fr fr.

🌸 PROLOG 🌸

This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ β€” consult the corresponding Linux manual page for details on Linux behavior β€” or the interface may not be implemented on Linux. πŸ’…


✨ NAME ✨

wcswidth β€” number of column positions of a wide-character string πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <wchar.h>

int wcswidth(const wchar_t *pwcs, size_t n);

πŸ’œ DESCRIPTION πŸ’œ

So like, wcswidth() figures out how many column positions you need for n wide-character codes in the string that pwcs is pointing at. πŸ‘‘

And if a null wide-character code shows up before you've burned through all n wide-character codes? Then it just does fewer than n. Not me being flexible, it's literally in the spec. 🫢


πŸ”₯ RETURN VALUE πŸ”₯

wcswidth() does one of these three iconic things:

  • returns 0 β€” if pwcs points to a null wide-character code πŸ’€
  • returns the number of column positions that the wide-character string pointed to by pwcs will occupy ⭐
  • returns -1 β€” if any of the first n wide-character codes in the wide-character string pointed to by pwcs is not a printable wide-character code 😭

periodt.


πŸ™ˆ ERRORS πŸ™ˆ

No errors are defined. slay, no drama.

The following sections are informative. (iykyk β€” that means they're the bonus content, not the rules.)


πŸ“ EXAMPLES πŸ“

None. πŸ’€ literally nothing. the example section said "no thoughts, head empty."


🌈 APPLICATION USAGE 🌈

Okay so important lore: this function was removed from the final ISO/IEC 9899:1990/Amendment 1:1995 (E). gone. and also β€” the return value for a non-printable wide character is not specified. so like, don't go trusting it for that case, bestie. πŸ™ˆ


🧚 RATIONALE 🧚

None.


πŸ‘‘ FUTURE DIRECTIONS πŸ‘‘

None.


πŸ’« SEE ALSO πŸ’«

  • wcwidth()
  • The Base Definitions volume of POSIX.1‐2017, Section 3.103, Column Position, <wchar.h>

Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


and that's the whole page, bestie!! 🫢 this one dropped in 2017, brought to you by the absolute icons at IEEE / The Open Group, and it lives under the name WCSWIDTH(3POSIX). go forth and count your columns, main character. πŸ’…βœ¨