in_wchstr(3NCURSES)

πŸ’– in_wchstr β€” get a curses complex character string from a window πŸ’–

okay bestie, welcome to in_wchstr(3NCURSES) β€” yes that's the manual name, it lives in section 3NCURSES and it's literally all about scooping a whole complex character string out of a curses window. no cap. let's get into it 🫢


✨ NAME ✨

in_wchstr, in_wchnstr, win_wchstr, win_wchnstr, mvin_wchstr, mvin_wchnstr, mvwin_wchstr, mvwin_wchnstr β€” get a curses complex character string from a window πŸ‘‘


🌸 SYNOPSIS 🌸

#include <curses.h>

int in_wchstr(cchar_t * wchstr);
int win_wchstr(WINDOW * win, cchar_t * wchstr);
int mvin_wchstr(int y, int x, cchar_t * wchstr);
int mvwin_wchstr(WINDOW * win, int y, int x, cchar_t * wchstr);

int in_wchnstr(cchar_t * wchstr, int n);
int win_wchnstr(WINDOW * win, cchar_t * wchstr, int n);
int mvin_wchnstr(int y, int x, cchar_t * wchstr, int n);
int mvwin_wchnstr(WINDOW * win, int y, int x, cchar_t * wchstr, int n)

(yes the last one is missing its semicolon, that's how it is in the source, we don't fix, we don't judge, we just vibe πŸ’…)


πŸ¦‹ DESCRIPTION πŸ¦‹

so win_wchstr pulls a curses complex character string out of a curses window called win, starting right at the cursor and going until the end of the line, then stashes it in wchstr and terminates it with a wide null curses character. that's the whole move, and it ate ✨

win_wchnstr does the exact same thing, but it copies at most n curses complex characters from win. and here's the tea: if n is negative that means no limit at all, so win_wchnstr just starts acting like win_wchstr. iconic behaviour honestly.

also, if you wanna know about all the variants of these functions, ncurses(3NCURSES) has the whole lore. iykyk πŸ’œ


πŸ’€ RETURN VALUE πŸ’€

these functions return OK when everything slays and ERR when it does not. simple as that.

in ncurses, these functions fail if:

  • the curses screen has not been initialized πŸ™ˆ
  • (for the functions that take a WINDOW pointer argument) win is a null pointer
  • wchstr is a null pointer

and the ones prefixed with β€œmv” first do a little cursor movement moment, and they fail if the position (y, x) is outside the window boundaries. boundaries are boundaries bestie 🚧


πŸŽ€ NOTES πŸŽ€

  • all of these functions except win_wchnstr may be implemented as macros. surprises abound πŸ’…
  • reading a line that overflows the array pointed to by wchstr and its variants causes undefined results. like, undefined-undefined. not a vibe. instead, use the n-infixed functions with a positive n argument that is no larger than the size of the buffer backing wchstr. protect your buffer, protect your peace 🫢
fr fr do not skip the buffer size thing, undefined results is not the main character energy you want

🌈 PORTABILITY 🌈

X/Open Curses Issue 4 describes these functions. it specifies no error conditions for them. so like, do with that what you will 🧚


⭐ HISTORY ⭐

  • X/Open Curses Issue 4 (1995) initially specified these functions ✨
  • the System V Interface Definition Version 4 of the same year specified a function named winwchstr (plus the usual variants). note: no underscore, we love a subtle rebrand 😭
  • that one was a later addition to SVr4.x and did not appear in the first SVr4 (1989) πŸ•°οΈ
  • and it differed from X/Open's later win_wchstr because it took an argument of type pointer-to-chtype instead of pointer-to-cchar_t. tiny type change, huge consequences πŸ’€

πŸ‘‘ SEE ALSO πŸ‘‘

  • inchstr(3NCURSES) β€” describes comparable functions of the ncurses library in its non-wide-character configuration
  • ncurses(3NCURSES)
  • inwstr(3NCURSES)
  • in_wch(3NCURSES)

and that's the whole page bestie!! this was ncurses 6.6, dated 2025-10-20, and it's the in_wchstr(3NCURSES) page so you know exactly where to find it again πŸ’– go forth and read your complex character strings responsibly, mwah πŸŽ€πŸ’…

πŸ“¦ where this page comes from