From ed2329892971115d2d68bbf3fc928cea3329d056 Mon Sep 17 00:00:00 2001 From: fxliang Date: Sat, 24 Jan 2026 15:30:39 +0800 Subject: [PATCH 1/4] fix: rime::path to ostream fails with c++20 --- src/rime/common.h | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/rime/common.h b/src/rime/common.h index 01f068e87e..24d61c3847 100644 --- a/src/rime/common.h +++ b/src/rime/common.h @@ -26,6 +26,10 @@ #ifdef RIME_ENABLE_LOGGING #include +#ifdef _WIN32 +#include +#endif + #else #include "no_logging.h" #endif // RIME_ENABLE_LOGGING @@ -104,6 +108,26 @@ class path : public std::filesystem::path { path& operator/=(const std::string& p) { return *this /= path(p); } path& operator/=(const char* p) { return *this /= path(p); } + std::string utf8string() const { +#ifdef _WIN32 + // Use Windows API for UTF-16 -> UTF-8 + auto wstr = this->wstring(); + if (wstr.empty()) { + return std::string{}; + } + int cb_utf8 = WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, nullptr, 0, + nullptr, nullptr); + if (cb_utf8 <= 1) { // only null terminator + return std::string{}; + } + std::string result(cb_utf8 - 1, '\0'); + WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, &result[0], cb_utf8, + nullptr, nullptr); + return result; +#else + return this->string(); +#endif + } friend path operator/(const path& lhs, const path& rhs) { return path(lhs) /= rhs; } @@ -128,7 +152,7 @@ class path : public std::filesystem::path { } #ifdef RIME_ENABLE_LOGGING friend std::ostream& operator<<(std::ostream& os, const path& p) { - return os << p.u8string(); + return os << p.utf8string(); } #endif }; From fb1b6650de907c1131f5f05e427488245d5fe35c Mon Sep 17 00:00:00 2001 From: fxliang Date: Sat, 24 Jan 2026 22:34:23 +0800 Subject: [PATCH 2/4] refactor: c++20 standard supported --- CMakeLists.txt | 1 + src/rime/common.h | 35 +++++++++++++---------------- src/rime/config/config_data.cc | 2 +- src/rime/dict/dict_compiler.cc | 2 +- src/rime/dict/entry_collector.cc | 2 +- src/rime/dict/user_db.cc | 2 +- src/rime/dict/vocabulary.h | 2 ++ src/rime/gear/simplifier.cc | 4 ++-- src/rime/lever/deployment_tasks.cc | 16 ++++++------- src/rime/lever/switcher_settings.cc | 2 +- src/rime/lever/user_dict_manager.cc | 2 +- src/rime/resource.cc | 2 +- tools/rime_table_decompiler.cc | 2 +- 13 files changed, 36 insertions(+), 38 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 010d6ed8e7..c8759052af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -171,6 +171,7 @@ if(MSVC) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi") set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF") add_definitions("/wd4244 /wd4996") + add_compile_options("/Zc:__cplusplus") # large address aware set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE") diff --git a/src/rime/common.h b/src/rime/common.h index 24d61c3847..22f8db946f 100644 --- a/src/rime/common.h +++ b/src/rime/common.h @@ -26,10 +26,6 @@ #ifdef RIME_ENABLE_LOGGING #include -#ifdef _WIN32 -#include -#endif - #else #include "no_logging.h" #endif // RIME_ENABLE_LOGGING @@ -108,24 +104,23 @@ class path : public std::filesystem::path { path& operator/=(const std::string& p) { return *this /= path(p); } path& operator/=(const char* p) { return *this /= path(p); } + path stem() const { return path(fs_path::stem()); } + path filename() const { return path(fs_path::filename()); } + path extension() const { return path(fs_path::extension()); } std::string utf8string() const { -#ifdef _WIN32 - // Use Windows API for UTF-16 -> UTF-8 - auto wstr = this->wstring(); - if (wstr.empty()) { - return std::string{}; - } - int cb_utf8 = WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, nullptr, 0, - nullptr, nullptr); - if (cb_utf8 <= 1) { // only null terminator - return std::string{}; - } - std::string result(cb_utf8 - 1, '\0'); - WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, &result[0], cb_utf8, - nullptr, nullptr); - return result; +#if __cplusplus >= 202002L + const auto u8s = this->u8string(); + return std::string(u8s.begin(), u8s.end()); +#else + return this->u8string(); +#endif + } + std::string generic_utf8string() const { +#if __cplusplus >= 202002L + const auto u8s = this->generic_u8string(); + return std::string(u8s.begin(), u8s.end()); #else - return this->string(); + return this->generic_u8string(); #endif } friend path operator/(const path& lhs, const path& rhs) { diff --git a/src/rime/config/config_data.cc b/src/rime/config/config_data.cc index e3e73dbd05..fdd5918487 100644 --- a/src/rime/config/config_data.cc +++ b/src/rime/config/config_data.cc @@ -66,7 +66,7 @@ bool ConfigData::LoadFromFile(const path& file_path, ConfigCompiler* compiler) { modified_ = false; root.reset(); if (!std::filesystem::exists(file_path)) { - if (!boost::ends_with(file_path.u8string(), ".custom.yaml")) + if (!boost::ends_with(file_path.utf8string(), ".custom.yaml")) LOG(WARNING) << "nonexistent config file '" << file_path << "'."; return false; } diff --git a/src/rime/dict/dict_compiler.cc b/src/rime/dict/dict_compiler.cc index 5996ee2cc3..2f91b5671d 100644 --- a/src/rime/dict/dict_compiler.cc +++ b/src/rime/dict/dict_compiler.cc @@ -209,7 +209,7 @@ bool DictCompiler::Compile(const path& schema_file) { static path relocate_target(const path& source_path, ResourceResolver* target_resolver) { - auto resource_id = source_path.filename().u8string(); + auto resource_id = source_path.filename().utf8string(); return target_resolver->ResolvePath(resource_id); } diff --git a/src/rime/dict/entry_collector.cc b/src/rime/dict/entry_collector.cc index 48d9402753..e4e830aba4 100644 --- a/src/rime/dict/entry_collector.cc +++ b/src/rime/dict/entry_collector.cc @@ -56,7 +56,7 @@ void EntryCollector::LoadPresetVocabulary(DictSettings* settings) { void EntryCollector::Collect(const path& dict_file) { LOG(INFO) << "collecting entries from " << dict_file; - current_dict_file = dict_file.u8string(); + current_dict_file = dict_file.utf8string(); line_number = 0; // read table std::ifstream fin(dict_file.c_str()); diff --git a/src/rime/dict/user_db.cc b/src/rime/dict/user_db.cc index e8f6788755..031d240c23 100644 --- a/src/rime/dict/user_db.cc +++ b/src/rime/dict/user_db.cc @@ -108,7 +108,7 @@ bool UserDbHelper::UpdateUserInfo() { } bool UserDbHelper::IsUniformFormat(const path& file_path) { - return boost::ends_with(file_path.filename().u8string(), + return boost::ends_with(file_path.filename().utf8string(), plain_userdb_extension); } diff --git a/src/rime/dict/vocabulary.h b/src/rime/dict/vocabulary.h index c7753d942b..41357fef5b 100644 --- a/src/rime/dict/vocabulary.h +++ b/src/rime/dict/vocabulary.h @@ -40,6 +40,8 @@ struct ShortDictEntry { double weight = 0.0; ShortDictEntry() = default; + ShortDictEntry(const string& t, const Code& c, double w) + : text(t), code(c), weight(w) {} bool operator<(const ShortDictEntry& other) const; }; diff --git a/src/rime/gear/simplifier.cc b/src/rime/gear/simplifier.cc index b337cf1a66..3ab82bcccf 100644 --- a/src/rime/gear/simplifier.cc +++ b/src/rime/gear/simplifier.cc @@ -41,7 +41,7 @@ class Opencc { opencc::Config config; try { // opencc accepts file path encoded in UTF-8. - converter_ = config.NewFromFile(config_path_.u8string()); + converter_ = config.NewFromFile(config_path_.utf8string()); const list conversions = converter_->GetConversionChain()->GetConversions(); @@ -315,7 +315,7 @@ Simplifier* SimplifierComponent::Create(const Ticket& ticket) { return new Simplifier(ticket, opencc); } path opencc_config_path = path(opencc_config); - if (opencc_config_path.extension().u8string() == ".ini") { + if (opencc_config_path.extension().utf8string() == ".ini") { LOG(ERROR) << "please upgrade opencc_config to an opencc 1.0 config file."; return nullptr; } diff --git a/src/rime/lever/deployment_tasks.cc b/src/rime/lever/deployment_tasks.cc index 6e6ff89570..8ef312ade0 100644 --- a/src/rime/lever/deployment_tasks.cc +++ b/src/rime/lever/deployment_tasks.cc @@ -52,8 +52,8 @@ bool DetectModifications::Run(Deployer* deployer) { for (fs::directory_iterator iter(p), end; iter != end; ++iter) { path entry(iter->path()); if (fs::is_regular_file(fs::canonical(entry)) && - entry.extension().u8string() == ".yaml" && - entry.filename().u8string() != "user.yaml") { + entry.extension().utf8string() == ".yaml" && + entry.filename().utf8string() != "user.yaml") { last_modified = (std::max)(last_modified, filesystem::to_time_t(fs::last_write_time(entry))); @@ -460,7 +460,7 @@ bool PrebuildAllSchemas::Run(Deployer* deployer) { for (fs::directory_iterator iter(shared_data_path), end; iter != end; ++iter) { path entry(iter->path()); - if (boost::ends_with(entry.filename().u8string(), ".schema.yaml")) { + if (boost::ends_with(entry.filename().utf8string(), ".schema.yaml")) { the t(new SchemaUpdate(entry)); if (!t->Run(deployer)) success = false; @@ -525,7 +525,7 @@ bool UserDictSync::Run(Deployer* deployer) { } static bool IsCustomizedCopy(const path& file_path) { - auto file_name = file_path.filename().u8string(); + auto file_name = file_path.filename().utf8string(); if (boost::ends_with(file_name, ".yaml") && !boost::ends_with(file_name, ".custom.yaml")) { Config config; @@ -556,7 +556,7 @@ bool BackupConfigFiles::Run(Deployer* deployer) { path entry(iter->path()); if (!fs::is_regular_file(entry)) continue; - auto file_extension = entry.extension().u8string(); + auto file_extension = entry.extension().utf8string(); bool is_yaml_file = file_extension == ".yaml"; bool is_text_file = file_extension == ".txt"; if (!is_yaml_file && !is_text_file) @@ -596,7 +596,7 @@ bool CleanupTrash::Run(Deployer* deployer) { path entry(iter->path()); if (!fs::is_regular_file(entry)) continue; - auto file_name = entry.filename().u8string(); + auto file_name = entry.filename().utf8string(); if (file_name == "rime.log" || boost::ends_with(file_name, ".bin") || boost::ends_with(file_name, ".reverse.kct") || boost::ends_with(file_name, ".userdb.kct.old") || @@ -650,7 +650,7 @@ bool CleanOldLogFiles::Run(Deployer* deployer) { try { // preparing files for (const auto& entry : fs::directory_iterator(dir)) { - const string& file_name(entry.path().filename().u8string()); + const string& file_name(path(entry.path().filename()).utf8string()); if (entry.is_regular_file() && !entry.is_symlink() && boost::starts_with(file_name, app_name) && boost::ends_with(file_name, ".log") && @@ -658,7 +658,7 @@ bool CleanOldLogFiles::Run(Deployer* deployer) { files_to_remove.push_back(entry.path()); } else if (entry.is_symlink()) { auto target = fs::read_symlink(entry.path()); - const string& target_file_name(target.filename().u8string()); + const string& target_file_name(path(target.filename()).utf8string()); if (boost::starts_with(target_file_name, app_name) && boost::ends_with(target_file_name, ".log")) { files_in_use.insert(target); diff --git a/src/rime/lever/switcher_settings.cc b/src/rime/lever/switcher_settings.cc index ad8c91608d..de01cfc532 100644 --- a/src/rime/lever/switcher_settings.cc +++ b/src/rime/lever/switcher_settings.cc @@ -53,7 +53,7 @@ void SwitcherSettings::GetAvailableSchemasFromDirectory(const path& dir) { } for (fs::directory_iterator it(dir), end; it != end; ++it) { path file_path(it->path()); - if (boost::ends_with(file_path.u8string(), ".schema.yaml")) { + if (boost::ends_with(file_path.utf8string(), ".schema.yaml")) { Config config; if (config.LoadFromFile(file_path)) { SchemaInfo info; diff --git a/src/rime/lever/user_dict_manager.cc b/src/rime/lever/user_dict_manager.cc index e0331e4c07..5376094a60 100644 --- a/src/rime/lever/user_dict_manager.cc +++ b/src/rime/lever/user_dict_manager.cc @@ -40,7 +40,7 @@ void UserDictManager::GetUserDictList(UserDictList* user_dict_list, return; } for (fs::directory_iterator it(path_), end; it != end; ++it) { - string name = it->path().filename().u8string(); + string name = path(it->path().filename()).utf8string(); if (boost::ends_with(name, component->extension())) { boost::erase_last(name, component->extension()); user_dict_list->push_back(name); diff --git a/src/rime/resource.cc b/src/rime/resource.cc index 045e047f8a..737a9806d8 100644 --- a/src/rime/resource.cc +++ b/src/rime/resource.cc @@ -10,7 +10,7 @@ namespace rime { string ResourceResolver::ToResourceId(const string& file_path) const { - string string_path = path(file_path).generic_u8string(); + string string_path = path(file_path).generic_utf8string(); bool has_prefix = boost::starts_with(string_path, type_.prefix); bool has_suffix = boost::ends_with(string_path, type_.suffix); size_t start = (has_prefix ? type_.prefix.length() : 0); diff --git a/tools/rime_table_decompiler.cc b/tools/rime_table_decompiler.cc index 06e265fc27..bcbc8d4165 100644 --- a/tools/rime_table_decompiler.cc +++ b/tools/rime_table_decompiler.cc @@ -122,7 +122,7 @@ int main(int argc, char* argv[]) { fout << "# Rime dictionary\n\n"; fout << "---\n" "name: " - << file_path.stem().u8string() + << rime::path(file_path).stem().utf8string() << "\n" "version: \"1.0\"\n" "...\n\n"; From b41e39deb5f6e277e161a1b8bb59004e418e2f7a Mon Sep 17 00:00:00 2001 From: fxliang Date: Sun, 25 Jan 2026 23:10:46 +0800 Subject: [PATCH 3/4] rename utf8string to string_utf8 --- src/rime/common.h | 8 +++++--- src/rime/config/config_data.cc | 2 +- src/rime/dict/dict_compiler.cc | 2 +- src/rime/dict/entry_collector.cc | 2 +- src/rime/dict/user_db.cc | 2 +- src/rime/gear/simplifier.cc | 4 ++-- src/rime/lever/deployment_tasks.cc | 16 ++++++++-------- src/rime/lever/switcher_settings.cc | 2 +- src/rime/lever/user_dict_manager.cc | 2 +- src/rime/resource.cc | 2 +- tools/rime_table_decompiler.cc | 2 +- 11 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/rime/common.h b/src/rime/common.h index 22f8db946f..b359b34041 100644 --- a/src/rime/common.h +++ b/src/rime/common.h @@ -107,7 +107,8 @@ class path : public std::filesystem::path { path stem() const { return path(fs_path::stem()); } path filename() const { return path(fs_path::filename()); } path extension() const { return path(fs_path::extension()); } - std::string utf8string() const { + // return UTF-8 encoded std::string + std::string string_utf8() const { #if __cplusplus >= 202002L const auto u8s = this->u8string(); return std::string(u8s.begin(), u8s.end()); @@ -115,7 +116,8 @@ class path : public std::filesystem::path { return this->u8string(); #endif } - std::string generic_utf8string() const { + // return UTF-8 encoded std::string of generic format + std::string generic_string_utf8() const { #if __cplusplus >= 202002L const auto u8s = this->generic_u8string(); return std::string(u8s.begin(), u8s.end()); @@ -147,7 +149,7 @@ class path : public std::filesystem::path { } #ifdef RIME_ENABLE_LOGGING friend std::ostream& operator<<(std::ostream& os, const path& p) { - return os << p.utf8string(); + return os << p.string_utf8(); } #endif }; diff --git a/src/rime/config/config_data.cc b/src/rime/config/config_data.cc index fdd5918487..d06670dcd3 100644 --- a/src/rime/config/config_data.cc +++ b/src/rime/config/config_data.cc @@ -66,7 +66,7 @@ bool ConfigData::LoadFromFile(const path& file_path, ConfigCompiler* compiler) { modified_ = false; root.reset(); if (!std::filesystem::exists(file_path)) { - if (!boost::ends_with(file_path.utf8string(), ".custom.yaml")) + if (!boost::ends_with(file_path.string_utf8(), ".custom.yaml")) LOG(WARNING) << "nonexistent config file '" << file_path << "'."; return false; } diff --git a/src/rime/dict/dict_compiler.cc b/src/rime/dict/dict_compiler.cc index 2f91b5671d..982ef0926e 100644 --- a/src/rime/dict/dict_compiler.cc +++ b/src/rime/dict/dict_compiler.cc @@ -209,7 +209,7 @@ bool DictCompiler::Compile(const path& schema_file) { static path relocate_target(const path& source_path, ResourceResolver* target_resolver) { - auto resource_id = source_path.filename().utf8string(); + auto resource_id = source_path.filename().string_utf8(); return target_resolver->ResolvePath(resource_id); } diff --git a/src/rime/dict/entry_collector.cc b/src/rime/dict/entry_collector.cc index e4e830aba4..e1c0d00172 100644 --- a/src/rime/dict/entry_collector.cc +++ b/src/rime/dict/entry_collector.cc @@ -56,7 +56,7 @@ void EntryCollector::LoadPresetVocabulary(DictSettings* settings) { void EntryCollector::Collect(const path& dict_file) { LOG(INFO) << "collecting entries from " << dict_file; - current_dict_file = dict_file.utf8string(); + current_dict_file = dict_file.string_utf8(); line_number = 0; // read table std::ifstream fin(dict_file.c_str()); diff --git a/src/rime/dict/user_db.cc b/src/rime/dict/user_db.cc index 031d240c23..95a0971902 100644 --- a/src/rime/dict/user_db.cc +++ b/src/rime/dict/user_db.cc @@ -108,7 +108,7 @@ bool UserDbHelper::UpdateUserInfo() { } bool UserDbHelper::IsUniformFormat(const path& file_path) { - return boost::ends_with(file_path.filename().utf8string(), + return boost::ends_with(file_path.filename().string_utf8(), plain_userdb_extension); } diff --git a/src/rime/gear/simplifier.cc b/src/rime/gear/simplifier.cc index 3ab82bcccf..6cc112db64 100644 --- a/src/rime/gear/simplifier.cc +++ b/src/rime/gear/simplifier.cc @@ -41,7 +41,7 @@ class Opencc { opencc::Config config; try { // opencc accepts file path encoded in UTF-8. - converter_ = config.NewFromFile(config_path_.utf8string()); + converter_ = config.NewFromFile(config_path_.string_utf8()); const list conversions = converter_->GetConversionChain()->GetConversions(); @@ -315,7 +315,7 @@ Simplifier* SimplifierComponent::Create(const Ticket& ticket) { return new Simplifier(ticket, opencc); } path opencc_config_path = path(opencc_config); - if (opencc_config_path.extension().utf8string() == ".ini") { + if (opencc_config_path.extension().string_utf8() == ".ini") { LOG(ERROR) << "please upgrade opencc_config to an opencc 1.0 config file."; return nullptr; } diff --git a/src/rime/lever/deployment_tasks.cc b/src/rime/lever/deployment_tasks.cc index 8ef312ade0..aa3ca7357c 100644 --- a/src/rime/lever/deployment_tasks.cc +++ b/src/rime/lever/deployment_tasks.cc @@ -52,8 +52,8 @@ bool DetectModifications::Run(Deployer* deployer) { for (fs::directory_iterator iter(p), end; iter != end; ++iter) { path entry(iter->path()); if (fs::is_regular_file(fs::canonical(entry)) && - entry.extension().utf8string() == ".yaml" && - entry.filename().utf8string() != "user.yaml") { + entry.extension().string_utf8() == ".yaml" && + entry.filename().string_utf8() != "user.yaml") { last_modified = (std::max)(last_modified, filesystem::to_time_t(fs::last_write_time(entry))); @@ -460,7 +460,7 @@ bool PrebuildAllSchemas::Run(Deployer* deployer) { for (fs::directory_iterator iter(shared_data_path), end; iter != end; ++iter) { path entry(iter->path()); - if (boost::ends_with(entry.filename().utf8string(), ".schema.yaml")) { + if (boost::ends_with(entry.filename().string_utf8(), ".schema.yaml")) { the t(new SchemaUpdate(entry)); if (!t->Run(deployer)) success = false; @@ -525,7 +525,7 @@ bool UserDictSync::Run(Deployer* deployer) { } static bool IsCustomizedCopy(const path& file_path) { - auto file_name = file_path.filename().utf8string(); + auto file_name = file_path.filename().string_utf8(); if (boost::ends_with(file_name, ".yaml") && !boost::ends_with(file_name, ".custom.yaml")) { Config config; @@ -556,7 +556,7 @@ bool BackupConfigFiles::Run(Deployer* deployer) { path entry(iter->path()); if (!fs::is_regular_file(entry)) continue; - auto file_extension = entry.extension().utf8string(); + auto file_extension = entry.extension().string_utf8(); bool is_yaml_file = file_extension == ".yaml"; bool is_text_file = file_extension == ".txt"; if (!is_yaml_file && !is_text_file) @@ -596,7 +596,7 @@ bool CleanupTrash::Run(Deployer* deployer) { path entry(iter->path()); if (!fs::is_regular_file(entry)) continue; - auto file_name = entry.filename().utf8string(); + auto file_name = entry.filename().string_utf8(); if (file_name == "rime.log" || boost::ends_with(file_name, ".bin") || boost::ends_with(file_name, ".reverse.kct") || boost::ends_with(file_name, ".userdb.kct.old") || @@ -650,7 +650,7 @@ bool CleanOldLogFiles::Run(Deployer* deployer) { try { // preparing files for (const auto& entry : fs::directory_iterator(dir)) { - const string& file_name(path(entry.path().filename()).utf8string()); + const string& file_name(path(entry.path().filename()).string_utf8()); if (entry.is_regular_file() && !entry.is_symlink() && boost::starts_with(file_name, app_name) && boost::ends_with(file_name, ".log") && @@ -658,7 +658,7 @@ bool CleanOldLogFiles::Run(Deployer* deployer) { files_to_remove.push_back(entry.path()); } else if (entry.is_symlink()) { auto target = fs::read_symlink(entry.path()); - const string& target_file_name(path(target.filename()).utf8string()); + const string& target_file_name(path(target.filename()).string_utf8()); if (boost::starts_with(target_file_name, app_name) && boost::ends_with(target_file_name, ".log")) { files_in_use.insert(target); diff --git a/src/rime/lever/switcher_settings.cc b/src/rime/lever/switcher_settings.cc index de01cfc532..87d0e19e4e 100644 --- a/src/rime/lever/switcher_settings.cc +++ b/src/rime/lever/switcher_settings.cc @@ -53,7 +53,7 @@ void SwitcherSettings::GetAvailableSchemasFromDirectory(const path& dir) { } for (fs::directory_iterator it(dir), end; it != end; ++it) { path file_path(it->path()); - if (boost::ends_with(file_path.utf8string(), ".schema.yaml")) { + if (boost::ends_with(file_path.string_utf8(), ".schema.yaml")) { Config config; if (config.LoadFromFile(file_path)) { SchemaInfo info; diff --git a/src/rime/lever/user_dict_manager.cc b/src/rime/lever/user_dict_manager.cc index 5376094a60..0be9e310a3 100644 --- a/src/rime/lever/user_dict_manager.cc +++ b/src/rime/lever/user_dict_manager.cc @@ -40,7 +40,7 @@ void UserDictManager::GetUserDictList(UserDictList* user_dict_list, return; } for (fs::directory_iterator it(path_), end; it != end; ++it) { - string name = path(it->path().filename()).utf8string(); + string name = path(it->path().filename()).string_utf8(); if (boost::ends_with(name, component->extension())) { boost::erase_last(name, component->extension()); user_dict_list->push_back(name); diff --git a/src/rime/resource.cc b/src/rime/resource.cc index 737a9806d8..04beb6b8dd 100644 --- a/src/rime/resource.cc +++ b/src/rime/resource.cc @@ -10,7 +10,7 @@ namespace rime { string ResourceResolver::ToResourceId(const string& file_path) const { - string string_path = path(file_path).generic_utf8string(); + string string_path = path(file_path).generic_string_utf8(); bool has_prefix = boost::starts_with(string_path, type_.prefix); bool has_suffix = boost::ends_with(string_path, type_.suffix); size_t start = (has_prefix ? type_.prefix.length() : 0); diff --git a/tools/rime_table_decompiler.cc b/tools/rime_table_decompiler.cc index bcbc8d4165..05775a4860 100644 --- a/tools/rime_table_decompiler.cc +++ b/tools/rime_table_decompiler.cc @@ -122,7 +122,7 @@ int main(int argc, char* argv[]) { fout << "# Rime dictionary\n\n"; fout << "---\n" "name: " - << rime::path(file_path).stem().utf8string() + << rime::path(file_path).stem().string_utf8() << "\n" "version: \"1.0\"\n" "...\n\n"; From b57165f1e3d58ac32810727fa932bf297abefccb Mon Sep 17 00:00:00 2001 From: fxliang Date: Sun, 25 Jan 2026 23:14:09 +0800 Subject: [PATCH 4/4] fix warning arithmetic between different enumeration type when c++20 set --- include/darts.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/darts.h b/include/darts.h index 18bf988bab..632b3cbda7 100644 --- a/include/darts.h +++ b/include/darts.h @@ -1429,9 +1429,9 @@ class DoubleArrayBuilder { void clear(); private: - enum { BLOCK_SIZE = 256 }; - enum { NUM_EXTRA_BLOCKS = 16 }; - enum { NUM_EXTRAS = BLOCK_SIZE * NUM_EXTRA_BLOCKS }; + static const std::size_t BLOCK_SIZE = 256; + static const std::size_t NUM_EXTRA_BLOCKS = 16; + static const std::size_t NUM_EXTRAS = BLOCK_SIZE * NUM_EXTRA_BLOCKS; enum { UPPER_MASK = 0xFF << 21 }; enum { LOWER_MASK = 0xFF };