Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: under windows, librime doesn't support resource_id(file name) with non-ANSI characters, which is supported by code page. #804

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/rime/resource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
#include <boost/algorithm/string.hpp>
#include <filesystem>
#include <rime/resource.h>
#ifdef _WIN32
#define PATH(x) std::filesystem::u8path(x)
#else
#define PATH(x) std::filesystem::path(x)
#endif

namespace rime {

Expand All @@ -29,17 +34,15 @@ string ResourceResolver::ToFilePath(const string& resource_id) const {

std::filesystem::path ResourceResolver::ResolvePath(const string& resource_id) {
return std::filesystem::absolute(
root_path_ /
std::filesystem::path(type_.prefix + resource_id + type_.suffix));
root_path_ / PATH(type_.prefix + resource_id + type_.suffix));
}

std::filesystem::path FallbackResourceResolver::ResolvePath(
const string& resource_id) {
auto default_path = ResourceResolver::ResolvePath(resource_id);
if (!std::filesystem::exists(default_path)) {
auto fallback_path = std::filesystem::absolute(
fallback_root_path_ /
std::filesystem::path(type_.prefix + resource_id + type_.suffix));
fallback_root_path_ / PATH(type_.prefix + resource_id + type_.suffix));
if (std::filesystem::exists(fallback_path)) {
return fallback_path;
}
Expand Down
Loading