From a54c4b48fb0aa9c021f17a325df7b8a797870937 Mon Sep 17 00:00:00 2001 From: Aiken Harris Date: Fri, 26 Jun 2026 23:52:58 +0200 Subject: [PATCH] Add initial NLS support --- xtoskrnl/CMakeLists.txt | 1 + xtoskrnl/includes/rtl.hh | 1 + xtoskrnl/includes/rtl/nls.hh | 34 +++++++++ xtoskrnl/rtl/nls.cc | 130 +++++++++++++++++++++++++++++++++++ 4 files changed, 166 insertions(+) create mode 100644 xtoskrnl/includes/rtl/nls.hh create mode 100644 xtoskrnl/rtl/nls.cc diff --git a/xtoskrnl/CMakeLists.txt b/xtoskrnl/CMakeLists.txt index b9ed2f5..a028591 100644 --- a/xtoskrnl/CMakeLists.txt +++ b/xtoskrnl/CMakeLists.txt @@ -103,6 +103,7 @@ list(APPEND XTOSKRNL_SOURCE ${XTOSKRNL_SOURCE_DIR}/rtl/llist.cc ${XTOSKRNL_SOURCE_DIR}/rtl/math.cc ${XTOSKRNL_SOURCE_DIR}/rtl/memory.cc + ${XTOSKRNL_SOURCE_DIR}/rtl/nls.cc ${XTOSKRNL_SOURCE_DIR}/rtl/rbtree.cc ${XTOSKRNL_SOURCE_DIR}/rtl/sha1.cc ${XTOSKRNL_SOURCE_DIR}/rtl/string.cc diff --git a/xtoskrnl/includes/rtl.hh b/xtoskrnl/includes/rtl.hh index d42a3be..610ca79 100644 --- a/xtoskrnl/includes/rtl.hh +++ b/xtoskrnl/includes/rtl.hh @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include diff --git a/xtoskrnl/includes/rtl/nls.hh b/xtoskrnl/includes/rtl/nls.hh new file mode 100644 index 0000000..8174186 --- /dev/null +++ b/xtoskrnl/includes/rtl/nls.hh @@ -0,0 +1,34 @@ +/** + * PROJECT: ExectOS + * COPYRIGHT: See COPYING.md in the top level directory + * FILE: xtoskrnl/includes/rtl/nls.hh + * DESCRIPTION: National Language Support + * DEVELOPERS: Aiken Harris + */ + +#ifndef __XTOSKRNL_RTL_NLS_HH +#define __XTOSKRNL_RTL_NLS_HH + +#include + + +/* Runtime Library */ +namespace RTL +{ + class Nls + { + public: + STATIC XTAPI VOID GetDefaultCodePage(OUT PUSHORT AnsiCodePage, + OUT PUSHORT OemCodePage); + STATIC XTAPI VOID InitializeCodePageTable(IN PUSHORT TableBase, + OUT PCPTABLE_INFO CodePageTable); + STATIC XTAPI VOID InitializeNlsTables(IN PUSHORT AnsiTableBase, + IN PUSHORT OemTableBase, + IN PUSHORT CaseTableBase, + OUT PNLSTABLE_INFO NlsTable); + STATIC XTAPI WCHAR ToLowerUnicodeCharacter(IN WCHAR WideCHaracter); + STATIC XTAPI WCHAR ToUpperUnicodeCharacter(IN WCHAR WideCharacter); + }; +} + +#endif /* __XTOSKRNL_RTL_NLS_HH */ diff --git a/xtoskrnl/rtl/nls.cc b/xtoskrnl/rtl/nls.cc new file mode 100644 index 0000000..2c5658b --- /dev/null +++ b/xtoskrnl/rtl/nls.cc @@ -0,0 +1,130 @@ +/** + * PROJECT: ExectOS + * COPYRIGHT: See COPYING.md in the top level directory + * FILE: xtoskrnl/rtl/nls.cc + * DESCRIPTION: National Language Support + * DEVELOPERS: Aiken Harris + */ + +#include + + +/** + * Retrieves the default ANSI and OEM code page identifiers for the system. + * + * @param AnsiCodePage + * Receives the default ANSI code page identifier. + * + * @param OemCodePage + * Receives the default OEM code page identifier. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTAPI +VOID +RTL::Nls::GetDefaultCodePage(OUT PUSHORT AnsiCodePage, + OUT PUSHORT OemCodePage) +{ + /* No NLS support */ + UNIMPLEMENTED; + + /* Set fallback values to zero */ + *AnsiCodePage = 0; + *OemCodePage = 0; +} + +/** + * Initializes a code page table information structure from a raw table base pointer. + * + * @param TableBase + * Supplies a pointer to the raw code page data. + * + * @param CodePageTable + * Receives the initialized code page table information structure. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTAPI +VOID +RTL::Nls::InitializeCodePageTable(IN PUSHORT TableBase, + OUT PCPTABLE_INFO CodePageTable) +{ + /* No NLS support */ + UNIMPLEMENTED; +} + +/** + * Initializes the global NLS table information structure using raw table bases. + * + * @param AnsiTableBase + * Supplies a pointer to the raw ANSI translation table data. + * + * @param OemTableBase + * Supplies a pointer to the raw OEM translation table data. + * + * @param CaseTableBase + * Supplies a pointer to the raw Unicode uppercase/lowercase mapping table data. + * + * @param NlsTable + * Receives the fully initialized NLS table structure. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTAPI +VOID +RTL::Nls::InitializeNlsTables(IN PUSHORT AnsiTableBase, + IN PUSHORT OemTableBase, + IN PUSHORT CaseTableBase, + OUT PNLSTABLE_INFO NlsTable) +{ + /* No NLS support */ + UNIMPLEMENTED; +} + +/** + * Converts a wide character to its lowercase equivalent using Unicode rules. + * + * @param WideCharacter + * Supplies the Unicode wide character to convert. + * + * @return This routine returns the lowercase equivalent of the provided wide character. + * + * @since XT 1.0 + */ +XTAPI +WCHAR +RTL::Nls::ToLowerUnicodeCharacter(IN WCHAR WideCharacter) +{ + /* This is temporary wrapper with no NLS support */ + UNIMPLEMENTED; + + /* Fall back to the internal wide string character transformation engine */ + return RTL::WideString::ToLowerWideCharacter(WideCharacter); +} + +/** + * Converts a wide character to its uppercase equivalent using Unicode rules. + * + * @param WideCharacter + * Supplies the Unicode wide character to convert. + * + * @return This routine returns the uppercase equivalent of the provided wide character. + * + * @since XT 1.0 + */ +XTAPI +WCHAR +RTL::Nls::ToUpperUnicodeCharacter(IN WCHAR WideCharacter) +{ + /* This is temporary wrapper with no NLS support */ + UNIMPLEMENTED; + + /* Fallback to the internal wide string character transformation engine */ + return RTL::WideString::ToUpperWideCharacter(WideCharacter); +}