fix: Various more unicode issues

This commit is contained in:
WerWolv
2022-07-05 00:00:00 +02:00
parent 716d6ae850
commit 4cd390ab02
13 changed files with 115 additions and 51 deletions

View File

@@ -739,7 +739,7 @@ namespace hex::plugin::builtin {
void drawFileToolShredder() {
static bool shredding = false;
static auto selectedFile = [] { std::string s; s.reserve(0x1000); return s; }();
static std::u8string selectedFile;
static bool fastMode = false;
ImGui::TextUnformatted("hex.builtin.tools.file_tools.shredder.warning"_lang);
@@ -754,7 +754,7 @@ namespace hex::plugin::builtin {
ImGui::SameLine();
if (ImGui::Button("...")) {
fs::openFileBrowser(fs::DialogMode::Open, {}, [](const auto &path) {
selectedFile = path.string();
selectedFile = path.u8string();
});
}
@@ -883,11 +883,11 @@ namespace hex::plugin::builtin {
1
};
static bool splitting = false;
static auto selectedFile = [] { std::string s; s.reserve(0x1000); return s; }();
static auto baseOutputPath = [] { std::string s; s.reserve(0x1000); return s; }();
static u64 splitSize = sizes[0];
static int selectedItem = 0;
static bool splitting = false;
static std::u8string selectedFile;
static std::u8string baseOutputPath;
static u64 splitSize = sizes[0];
static int selectedItem = 0;
if (ImGui::BeginChild("split_settings", { 0, ImGui::GetTextLineHeightWithSpacing() * 7 }, true, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse)) {
ImGui::BeginDisabled(splitting);
@@ -896,7 +896,7 @@ namespace hex::plugin::builtin {
ImGui::SameLine();
if (ImGui::Button("...##input")) {
fs::openFileBrowser(fs::DialogMode::Open, {}, [](const auto &path) {
selectedFile = path.string();
selectedFile = path.u8string();
});
}
ImGui::SameLine();
@@ -906,7 +906,7 @@ namespace hex::plugin::builtin {
ImGui::SameLine();
if (ImGui::Button("...##output")) {
fs::openFileBrowser(fs::DialogMode::Save, {}, [](const auto &path) {
baseOutputPath = path.string();
baseOutputPath = path.u8string();
});
}
ImGui::SameLine();
@@ -960,7 +960,10 @@ namespace hex::plugin::builtin {
for (u64 offset = 0; offset < file.getSize(); offset += splitSize) {
task.update(offset);
fs::File partFile(baseOutputPath + hex::format(".{:05}", index), fs::File::Mode::Create);
std::fs::path path = baseOutputPath;
path += hex::format(".{:05}", index);
fs::File partFile(path, fs::File::Mode::Create);
if (!partFile.isValid()) {
View::showErrorPopup(hex::format("hex.builtin.tools.file_tools.splitter.error.create"_lang, index));
@@ -986,8 +989,8 @@ namespace hex::plugin::builtin {
void drawFileToolCombiner() {
static bool combining = false;
static std::vector<std::string> files;
static auto outputPath = [] { std::string s; s.reserve(0x1000); return s; }();
static std::vector<std::fs::path> files;
static std::u8string outputPath;
static u32 selectedIndex;
if (ImGui::BeginTable("files_table", 2, ImGuiTableFlags_SizingStretchProp)) {
@@ -1035,7 +1038,7 @@ namespace hex::plugin::builtin {
{
if (ImGui::Button("hex.builtin.tools.file_tools.combiner.add"_lang)) {
fs::openFileBrowser(fs::DialogMode::Open, {}, [](const auto &path) {
files.push_back(path.string());
files.push_back(path);
});
}
ImGui::SameLine();
@@ -1059,7 +1062,7 @@ namespace hex::plugin::builtin {
ImGui::SameLine();
if (ImGui::Button("...")) {
fs::openFileBrowser(fs::DialogMode::Save, {}, [](const auto &path) {
outputPath = path.string();
outputPath = path.u8string();
});
}
ImGui::SameLine();

View File

@@ -185,7 +185,7 @@ namespace hex::plugin::builtin {
}
ContentRegistry::FileHandler::add({ ".hexpat", ".pat" }, [](const std::fs::path &path) -> bool {
fs::File file(path.string(), fs::File::Mode::Read);
fs::File file(path, fs::File::Mode::Read);
if (file.isValid()) {
EventManager::post<RequestSetPatternLanguageCode>(file.readString());
@@ -619,7 +619,7 @@ namespace hex::plugin::builtin {
confirmButtons(
"hex.builtin.common.yes"_lang, "hex.builtin.common.no"_lang, [this] {
this->loadPatternFile(this->m_possiblePatternFiles[this->m_selectedPatternFile].string());
this->loadPatternFile(this->m_possiblePatternFiles[this->m_selectedPatternFile]);
ImGui::CloseCurrentPopup(); }, [] { ImGui::CloseCurrentPopup(); });
if (ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_Escape)))

View File

@@ -191,7 +191,7 @@ namespace hex::plugin::builtin {
[](const char *includeName, const char *, const char *, void *userData) -> const char * {
auto currFilePath = static_cast<const char *>(userData);
fs::File file((std::fs::path(currFilePath).parent_path() / includeName).string(), fs::File::Mode::Read);
fs::File file(std::fs::path(currFilePath).parent_path() / includeName, fs::File::Mode::Read);
if (!file.isValid())
return nullptr;

View File

@@ -84,7 +84,7 @@ namespace hex::plugin::builtin {
auto width = ImGui::GetWindowWidth();
ImGui::SetCursorPosX(width / 9);
if (ImGui::Button("hex.builtin.welcome.safety_backup.restore"_lang, ImVec2(width / 3, 0))) {
ProjectFile::load(s_safetyBackupPath.string());
ProjectFile::load(s_safetyBackupPath);
ProjectFile::markDirty();
ProjectFile::clearProjectFilePath();
@@ -403,9 +403,9 @@ namespace hex::plugin::builtin {
}
{
std::vector<std::string> recentFilesVector;
std::vector<std::u8string> recentFilesVector;
for (const auto &recentPath : s_recentFilePaths)
recentFilesVector.push_back(recentPath.string());
recentFilesVector.push_back(recentPath.u8string());
ContentRegistry::Settings::write("hex.builtin.setting.imhex", "hex.builtin.setting.imhex.recent_files", recentFilesVector);
}
@@ -450,7 +450,7 @@ namespace hex::plugin::builtin {
}
}
for (const auto &pathString : ContentRegistry::Settings::read("hex.builtin.setting.imhex", "hex.builtin.setting.imhex.recent_files")) {
for (const auto &pathString : ContentRegistry::Settings::read("hex.builtin.setting.imhex", "hex.builtin.setting.imhex.recent_files", std::vector<std::u8string>{ })) {
std::fs::path path = std::u8string(pathString.begin(), pathString.end());
if (fs::exists(path))
s_recentFilePaths.emplace_back(path);