vc_translate_unicode(9)
β¨ vc_translate_unicode(9) β Kernel API Manual β¨
okay so bestie, this is the page for vc_translate_unicode, straight out of the Kernel API Manual π
and it's literally the little function that stitches UTF-8 bytes together into a Unicode code point for the virtual console. grab a strawberry π and let's go.
πΈ SYNOPSIS πΈ
int vc_translate_unicode (struct vc_data *vc , int c , bool *rescan );
π ARGUMENTS π
vcβ the virtual console, obvs. it's the wholestruct vc_data *situation.cβ the UTF-8 byte you want translated. one single byte, bestie.rescanβ gets set totrueiffcwasn't consumed here and needs to be re-processed. so if this flips to true, that byte is coming back for round two π.
π DESCRIPTION π
so here's the tea β this function is building up a code point byte by byte, and it keeps its little bookkeeping in the vc_data struct:
vc_data.vc_utf_charis the being-constructed Unicode code point. the main character of the whole operation π.vc_data.vc_utf_countis the number of continuation bytes still expected to arrive. the countdown β³.vc_data.vc_nparis the number of continuation bytes arrived so far. the tally so far π.
π₯ RETURN π₯
the returns are giving very specific, so listen up:
-1β input OK so far,cconsumed, further bytes expected. we're mid-vibe, keep the bytes coming β¨.0xFFFDβ two whole possibilities, and yes you need to know both:- Possibility 1: input invalid,
cmay have been consumed (see desc. ofrescan). π - Possibility 2: input OK,
cconsumed, andU+FFFD is the resulting code point. U+FFFD is valid, REPLACEMENT CHARACTER. not a bug, that's just what it is π«Ά.
- Possibility 1: input invalid,
- otherwise β input OK,
cconsumed, resulting code point returned. slay, we got the whole character π.
π¦ SEE ALSO π¦
Kernel file ./drivers/tty/vt/vt.c plus a whole friend group of functions: vc_font_pitch(9), vc_font_size(9), vc_do_resize(9), __vc_resize(9), vt_resize(9), enum vc_ctl_state(9), vc_sanitize_unicode(9), vt_kmsg_redirect(9), con_is_bound(9), con_is_visible(9), con_debug_enter(9), con_debug_leave(9), do_unregister_con_driver(9).
fr fr,rescanis the one to watch β if it'strue, that byte did NOT get eaten here and needs re-processing. no cap.
that's the whole page, bestie π β sourced from ./drivers/tty/vt, dated October 2026, and it's the vc_translate_unicode(9) page from the Kernel API Manual. mwah, go read some more kernel docs π§ββοΈπΈ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms