wcwidth(3)
โจ wcwidth(3) โ the manual page bestie ๐
okay so this is a page from the Library Functions Manual (yes, the libc girlies) and honestly? it's a tiny function with main character energy. let's get into it ๐
๐ฆ NAME
wcwidth โ figure out how many columns a wide character takes up, bestie. that's it. that's the whole job.
๐ LIBRARY
Standard C library (libc, -lc) โ she's a classic, no cap.
๐ธ SYNOPSIS
#define _XOPEN_SOURCE /* See feature_test_macros(7) */
#include <wchar.h>
int wcwidth(wchar_t wc);
like, you gotta define _XOPEN_SOURCE first (peep feature_test_macros(7) for the lore ๐) and then pull in <wchar.h>.
๐ DESCRIPTION
so wcwidth() literally returns the number of columns you need to represent the wide character wc. that's the vibe.
- if
wcis a printable wide character, the value is at least 0 โจ - if
wcis the null wide character (L'\0'), the value is 0 ๐ซถ - otherwise? -1 gets returned, and honestly, same ๐
๐ RETURN VALUE
wcwidth() hands you back the number of column positions for wc. periodt. ๐
๐ ATTRIBUTES
for what all these words even mean, go look at attributes(7) โ iykyk.
here's the tea on wcwidth():
- Interface:
wcwidth() - Attribute: Thread safety
- Value: MT-Safe locale
โญ STANDARDS
POSIX.1-2008. iconic. certified. ๐ฏ
๐ง HISTORY
POSIX.1-2001 โ she's been around a minute.
and a lil throwback for you: before glibc 2.2.5, glibc was out here using this prototype instead:
int wcwidth(wint_t wc);
not me with the wint_t instead of wchar_t ๐ญ ancient times fr fr.
๐ฅ NOTES
the behavior of wcwidth() depends on the LC_CTYPE category of the current locale. so like... your locale is the one calling the shots here, not you. lowkey humbling. ๐ธ
๐ซถ SEE ALSO
vibe check: this is Linux man-pages 6.20, dated 2026-02-08, forwcwidth(3). slay, stay hydrated, and always define_XOPEN_SOURCEbefore you include anything ๐โจ
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: GPL-2.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms