wcswidth(3)

๐Ÿ’– NAME ๐Ÿ’–

wcswidth โ€” bestie, this is the one that tells u how many columns a fixed-size wide-character string is gonna take up โœจ


๐ŸŒธ LIBRARY ๐ŸŒธ

Standard C library (libc, -lc) ๐Ÿซถ


โœจ SYNOPSIS โœจ

#define _XOPEN_SOURCE             /* See feature_test_macros(7) */
#include <wchar.h>

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

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

okay so. wcswidth() looks at the wide-character string that s points to and tells u how many columns u need to represent it โ€” but only counting at most n wide characters. like, it's the fixed-size vibe, it stops at n and doesn't peek past it bestie ๐Ÿ’…

and listen โ€” if there's a nonprintable wide character somewhere in those characters? bestie it just returns -1. that's it. that's the whole plot. ๐Ÿ’€


๐ŸŒˆ RETURN VALUE ๐ŸŒˆ

wcswidth() hands u back the number of column positions for the wide-character string s, truncated to at most length n. that's the whole thing, no cap ๐Ÿ‘‘


๐Ÿ‘‘ ATTRIBUTES ๐Ÿ‘‘

for the tea on what all these terms even mean, go look at attributes(7) ๐Ÿซถ

  • Interface: wcswidth()
  • Attribute: Thread safety
  • Value: MT-Safe locale

โญ STANDARDS โญ

POSIX.1-2008. periodt.


๐ŸŽ€ HISTORY ๐ŸŽ€

POSIX.1-2001. yeah she's been around a minute, iconic behavior fr fr


๐Ÿ“ NOTES ๐Ÿ“

the way wcswidth() acts totally depends on the LC_CTYPE category of the current locale ๐Ÿ˜ญ so like, change ur locale, change ur whole answer. iykyk ๐Ÿ’œ


๐Ÿ’œ SEE ALSO ๐Ÿ’œ


mwah ๐Ÿ’‹ that's the whole page bestie โ€” from Linux man-pages 6.20, dated 2026-02-08, and it's wcswidth(3) if u ever gotta look her up again ๐Ÿซถโœจ

๐Ÿ“ฆ 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