From dfa795b26745ff1512e25403089cae0f3df80aff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laci=20b=C3=A1?= Date: Sat, 13 Nov 2021 23:51:29 +0100 Subject: [PATCH] Add reverse conversion from string to LCID --- src/include/86box/plat.h | 1 + src/win/win.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/include/86box/plat.h b/src/include/86box/plat.h index 148b396c3..ca116a684 100644 --- a/src/include/86box/plat.h +++ b/src/include/86box/plat.h @@ -123,6 +123,7 @@ extern void plat_resize(int x, int y); extern void plat_vidapi_enable(int enabled); extern void plat_vid_reload_options(void); extern uint32_t plat_language_code(char* langcode); +extern void plat_language_code_r(uint32_t lcid, char* outbuf, int len); /* Resource management. */ extern void set_language(uint32_t id); diff --git a/src/win/win.c b/src/win/win.c index 4c8e7ac27..80708a5ca 100644 --- a/src/win/win.c +++ b/src/win/win.c @@ -1221,6 +1221,22 @@ plat_language_code(char* langcode) return lcid; } +/* Converts back the language code to LCID */ +void +plat_language_code_r(uint32_t lcid, char* outbuf, int len) +{ + if (lcid == 0xFFFF) + { + strcpy(outbuf, "system"); + return; + } + + wchar_t buffer[LOCALE_NAME_MAX_LENGTH + 1]; + LCIDToLocaleName(lcid, buffer, LOCALE_NAME_MAX_LENGTH, 0); + + c16stombs(outbuf, buffer, len); +} + void take_screenshot(void) {