WCSWIDTH(3P)

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

okay bestie, welcome to the POSIX Programmer's Manual β€” yes, the one and only. this page is WCSWIDTH(3P), and before we get into it, the legal girlies have notes:

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 of Linux behavior), or the interface may not be implemented on Linux.

so like. it might be different on Linux. it might not exist on Linux at all. read the Linux page, she's telling you upfront. 🫢


✨ NAME ✨

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

she counts how much space your fancy wide characters take up on the screen, no cap.


🌸 SYNOPSIS 🌸

#include <wchar.h>

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

there she is. two args, int coming back at you. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea: the wcswidth() function shall determine the number of column positions required for n wide-character codes β€” or, plot twist, fewer than n wide-character codes if a null wide-character code shows up before you've burned through all n of them β€” in the string pointed to by pwcs.

basically: "how many columns of my terminal is this string gonna eat" and it stops counting early if it hits a null wide char. main character behavior honestly. ✨


πŸ‘‘ RETURN VALUE πŸ‘‘

the wcswidth() function either shall return:

  • 0 β€” if pwcs points to a null wide-character code. (empty vibes, zero columns, we love a clean slate πŸŽ€)
  • the number of column positions to be occupied by the wide-character string pointed to by pwcs β€” the normal slay case.
  • -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. 🚨 not printable = she's not gonna give you a number, she's gonna give you -1.

πŸ’€ ERRORS πŸ’€

No errors are defined.

like literally none. nothing to report. iconic.

The following sections are informative.


🌈 EXAMPLES 🌈

None.

ngl bestie, they gave us nothing. zero examples. an empty plate. 🍽️😭


🧚 APPLICATION USAGE 🧚

okay important lore drop: this function was removed from the final ISO/IEC 9899:1990/Amendment 1:1995 (E), and β€” heads up β€” the return value for a non-printable wide character is not specified. so don't go building your whole life on what happens when things get unprintable, iykyk. πŸ™ˆ


πŸ’œ RATIONALE πŸ’œ

None.

nothing. silence. the void. πŸ’€βœ¨


⭐ FUTURE DIRECTIONS ⭐

None.

no plans, no roadmap, she's just existing. periodt. πŸ‘‘


πŸ”₯ SEE ALSO πŸ”₯

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

go read those next, bestie, they're the supporting cast. 🫢


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, babe! brought to you by IEEE/The Open Group, 2017 β€” yes, the footer girlies β€” WCSWIDTH(3P), out. πŸ’–βœ¨πŸ’…

πŸ“¦ where this page comes from