Files
qemu-qemu-1/ui/cp437.h
Marc-André Lureau 5080dc706e ui/console-vc: add UTF-8 input decoding with CP437 rendering
The text console receives bytes that may be UTF-8 encoded (e.g. from
a guest running a modern distro), but currently treats each byte as a
raw character index into the VGA/CP437 font, producing garbled output
for any multi-byte sequence.

Add a UTF-8 decoder using Bjoern Hoehrmann's DFA. The DFA inherently
rejects overlong encodings, surrogates, and codepoints above U+10FFFF.
Completed codepoints are then mapped to CP437, unmappable characters are
displayed as '?'.

Note that QEMU has a "buffered" utf8 decoder in util/unicode.c, but
it is not a good fit for byte-per-byte decoding.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-05-09 10:24:37 +04:00

14 lines
223 B
C

/*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* Copyright (c) QEMU contributors
*/
#ifndef QEMU_CP437_H
#define QEMU_CP437_H
#include <stdint.h>
int unicode_to_cp437(uint32_t codepoint);
#endif /* QEMU_CP437_H */