mirror of
https://github.com/qemu/qemu.git
synced 2026-07-08 17:46:17 +00:00
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>
14 lines
223 B
C
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 */
|