UNICODE_WCWIDTH(3)

πŸ“¦
version 2.6.0 Β· 3 versions
, in nixpkgs unstable, ubuntu stonking

πŸ’– UNICODE_WCWIDTH(3) πŸ’–

ok bestie, so this is a page from the Courier Unicode Library manual, and we're gonna talk about figuring out how wide stuff is when you print it to a terminal. because apparently characters don't all take up one lil slot like you'd think. rude, honestly. πŸ¦‹


✨ NAME ✨

unicode_wcwidth, unicode_wcwidth_str β€” the width of a Unicode character string, no cap πŸŽ€


🌸 SYNOPSIS 🌸

#include <courier-unicode.h>

int unicode_wcwidth(char32_t c);

size_t unicode_wcwidth_str(const char32_t *str);

πŸ‘‘ DESCRIPTION πŸ‘‘

so unicode_wcwidth is the vibe-check function. you hand it one character, it tells you how much horizontal space that character eats up:

  • returns 1 for regular Unicode characters (the normal ones, the standard girlies)
  • returns 0 for control characters (they take up zero space, they're literally not even visible, main character energy but invisible 😭)
  • returns 2 for characters that normally take up the width of two regular characters on a text console (yeah, some of them are just Built Different and hog two slots) πŸ’…

then there's unicode_wcwidth_str, the group-chat version. it adds up unicode_wcwidth of all the characters in the null-terminated string and returns the total. so like, the whole squad's width combined. periodt. ✨


πŸ’€ BUGS πŸ’€

ok so here's the thing, and it's lowkey important β€” the width of a Unicode character is looked up in the Unicode database, and not your terminal's character set font. so it's not peeking at what your terminal is actually doing, it's trusting the database. hopefully your terminal's character set font is Unicide-compatible. πŸ™ˆ (that's what it says, bestie, i'm just the messenger)

ngl this is genuinely the kind of caveat that bites people. the function does not know what your font looks like. it knows what the database says. those can disagree and that's just the situation. 🫢

πŸ¦‹ SEE ALSO πŸ¦‹

go read these too, they're all part of the same lil ecosystem:


🌈 AUTHOR 🌈

Sam Varshavchik β€” Author πŸ‘‘


that's the whole page, bestie!! go measure some characters, stay iconic, and remember: width 0 is still a valid width, we don't discriminate here. πŸ’œ

β€” this masterpiece was brought to you by the Courier Unicode Library, dated 04/12/2026, and yes the manual page section is still UNICODE_WCWIDTH(3). mwah. πŸ’…πŸŽ€

πŸ“¦ where this page comes from