WCWIDTH(3P)

πŸ¦‹ WCWIDTH β€” okay bestie, let's talk column positions πŸ¦‹

so this is wcwidth(3P), from the POSIX Programmer's Manual β€” yes, the POSIX one, not the Linux one, and those two are not the same vibe, okay? Let's get into it.


✨ PROLOG ✨

Real talk before anything else: this manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ β€” so pls consult the corresponding Linux manual page for the deets on Linux behavior β€” or honestly, the interface may not even be implemented on Linux at all. Check before you commit, bestie. πŸ’…


🌸 NAME 🌸

wcwidth β€” literally just: the number of column positions of a wide-character code. That's it. That's the whole job. She's niche but she's essential.


πŸŽ€ SYNOPSIS πŸŽ€

#include <wchar.h>

int wcwidth(wchar_t wc);

πŸ’– DESCRIPTION πŸ’–

okay so here's the tea. wcwidth() shall determine the number of column positions required for the wide character wc. Column positions. Like, how much horizontal room does this little glyph take up on your terminal. 🫢

But here's the part where you have homework: the application shall ensure that the value of wc is a character representable as a wchar_t, and is a wide-character code corresponding to a valid character in the current locale. So locale-valid, wchar_t-representable, no funny business. ✨


πŸ‘‘ RETURN VALUE πŸ‘‘

So she returns one of three things, and you need to know which is which:

  • 0 β€” if wc is a null wide-character code. Zero columns, queen of taking up no space. πŸ’€
  • the number of column positions β€” the actual count of columns that the wide-character code wc will occupy. Main character energy, occupying her rightful space. πŸ‘‘
  • -1 β€” if wc does not correspond to a printable wide-character code. Not printable, not invited. πŸ™ˆ

🚫 ERRORS 🚫

No errors are defined. Iconic. No drama. Nothing to catch. ✨

Also, heads up: the following sections are informative. (Yes, that's the manpage talking, not me.)


πŸ¦‹ EXAMPLES πŸ¦‹

None. Nothing to see here, bestie, it's giving tumbleweed. πŸ’€


πŸ’… APPLICATION USAGE πŸ’…

Okay this part is important so pay attention:

This function was removed from the final ISO/IEC 9899:1990/Amendment 1:1995 (E). Gone. Removed. Not in there anymore. 😭

And the return value for a non-printable wide character is not specified. Not specified! So don't go building your whole life on that value, fr fr. ⚠️

Warning bestie: unspecified return value for non-printable wide characters means you should NOT assume anything about it. Do not pass go. Do not collect your column count.

🌈 RATIONALE 🌈

None. No rationale, no explanation, she simply is. 🧚


⭐ FUTURE DIRECTIONS ⭐

None. The future is wide open and also empty. Slay. ✨


πŸŽ€ SEE ALSO πŸŽ€

  • wcswidth()
  • The Base Definitions volume of POSIX.1‐2017, <wchar.h>

Go read wcswidth() next, they're besties, it's a whole thing. iykyk. 🫢


okay legal moment, do not skip, this is required reading:

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 β€” brought to you by IEEE/The Open Group, dated 2017, under the name WCWIDTH(3P). πŸ’œ go forth and measure your columns. periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from