mirror of
https://github.com/ipxe/ipxe
synced 2025-12-09 02:40:27 +03:00
[efi] Support Unicode character output via text console
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -26,6 +26,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
|||||||
#include <ipxe/efi/efi.h>
|
#include <ipxe/efi/efi.h>
|
||||||
#include <ipxe/efi/Protocol/ConsoleControl/ConsoleControl.h>
|
#include <ipxe/efi/Protocol/ConsoleControl/ConsoleControl.h>
|
||||||
#include <ipxe/ansiesc.h>
|
#include <ipxe/ansiesc.h>
|
||||||
|
#include <ipxe/utf8.h>
|
||||||
#include <ipxe/console.h>
|
#include <ipxe/console.h>
|
||||||
#include <ipxe/keymap.h>
|
#include <ipxe/keymap.h>
|
||||||
#include <ipxe/init.h>
|
#include <ipxe/init.h>
|
||||||
@@ -201,6 +202,9 @@ static struct ansiesc_context efi_ansiesc_ctx = {
|
|||||||
.handlers = efi_ansiesc_handlers,
|
.handlers = efi_ansiesc_handlers,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** EFI console UTF-8 accumulator */
|
||||||
|
static struct utf8_accumulator efi_utf8_acc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print a character to EFI console
|
* Print a character to EFI console
|
||||||
*
|
*
|
||||||
@@ -208,13 +212,25 @@ static struct ansiesc_context efi_ansiesc_ctx = {
|
|||||||
*/
|
*/
|
||||||
static void efi_putchar ( int character ) {
|
static void efi_putchar ( int character ) {
|
||||||
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *conout = efi_systab->ConOut;
|
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *conout = efi_systab->ConOut;
|
||||||
wchar_t wstr[] = { character, 0 };
|
wchar_t wstr[2];
|
||||||
|
|
||||||
/* Intercept ANSI escape sequences */
|
/* Intercept ANSI escape sequences */
|
||||||
character = ansiesc_process ( &efi_ansiesc_ctx, character );
|
character = ansiesc_process ( &efi_ansiesc_ctx, character );
|
||||||
if ( character < 0 )
|
if ( character < 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/* Accumulate Unicode characters */
|
||||||
|
character = utf8_accumulate ( &efi_utf8_acc, character );
|
||||||
|
if ( character == 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Treat unrepresentable (non-UCS2) characters as invalid */
|
||||||
|
if ( character & ~( ( wchar_t ) -1UL ) )
|
||||||
|
character = UTF8_INVALID;
|
||||||
|
|
||||||
|
/* Output character */
|
||||||
|
wstr[0] = character;
|
||||||
|
wstr[1] = L'\0';
|
||||||
conout->OutputString ( conout, wstr );
|
conout->OutputString ( conout, wstr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user