legacy_coding(3X)

πŸ’– legacy_coding β€” the ncurses library calls, bestie edition πŸ’–

okay so real talk, this page lives in the ncurses library calls section, and it's all about use_legacy_coding. she's a little extension, she's a little niche, and she is SO fun once you get her. let's go ✨


🌸 NAME 🌸

use_legacy_coding β€” override curses locale encoding checks


πŸŽ€ SYNOPSIS πŸŽ€

#include <curses.h>

int use_legacy_coding(int level);

✨ DESCRIPTION ✨

so use_legacy_coding is an ncurses extension to the curses library (yes, an extension, we'll get to that in a sec πŸ’…). what she does is let you customize the behavior of unctrl(3X), by suppressing isprint(3)-based checks inside the library β€” the ones that would normally make nonprinting characters get rendered in visible form.

important vibe check tho: this alteration only affects byte-wide characters with the most significant bit set. that's the whole scope. no cap.

the level parameter is what controls the result, and she's got three moods:

  • 0 β€” the library functions normally, rendering nonprinting characters as described in unctrl(3X).
  • 1 β€” the library ignores isprint for codes in the range 160-255.
  • 2 β€” the library ignores isprint for codes in the range 128-255. it also modifies the output of unctrl(3X), showing codes in the range 128-159 as is.

🫢 RETURN VALUE 🫢

if the curses screen has not been initialized, or if the level parameter is out of range, use_legacy_coding returns ERR. 😭

otherwise? she returns the previous level. cute, right? she's a gossip, she tells you what came before.


🌈 EXTENSIONS 🌈

use_legacy_coding is an ncurses extension. that's it, that's the note. she's not standard-library-core, she's ncurses-exclusive main character energy πŸ‘‘


πŸ¦‹ PORTABILITY πŸ¦‹

apps that employ ncurses extensions should condition their use on the visibility of the NCURSES_VERSION preprocessor macro.

like. if you're gonna use her, check that she's even invited to the party first. fr fr.


πŸ’œ HISTORY πŸ’œ

ncurses 5.6 (2006) introduced use_legacy_coding to support lynx(1)'s font-switching feature. iconic origin story honestly, she was built for a browser 🧚


⭐ AUTHORS ⭐

Thomas Dickey


πŸ”₯ SEE ALSO πŸ”₯

  • unctrl(3X)

and that's the whole page, babe πŸ’… this one shipped in ncurses 6.6, dated 2024-09-14 β€” go forth and encode responsibly πŸŽ€βœ¨

πŸ“¦ where this page comes from