From 171508fc4051e0a24130c4d15ba2e3ec58b43abb Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 12 Sep 2024 10:59:01 +0200 Subject: [PATCH] Fixed some encoding issues --- src/libslic3r/utils.cpp | 2 +- src/slic3r/GUI/DesktopIntegrationDialog.cpp | 2 +- src/slic3r/GUI/GUI_App.cpp | 4 ++-- src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp | 10 +++------- src/slic3r/GUI/PresetArchiveDatabase.cpp | 4 ++-- src/slic3r/Utils/Http.cpp | 2 +- 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/libslic3r/utils.cpp b/src/libslic3r/utils.cpp index 5e8b43cf37..cc7f448534 100644 --- a/src/libslic3r/utils.cpp +++ b/src/libslic3r/utils.cpp @@ -1161,7 +1161,7 @@ std::string log_memory_info(bool ignore_loglevel) out += "N/A"; #else // i.e. __linux__ size_t tSize = 0, resident = 0, share = 0; - std::ifstream buffer("/proc/self/statm"); + boost::nowide::ifstream buffer("/proc/self/statm"); if (buffer && (buffer >> tSize >> resident >> share)) { size_t page_size = (size_t)sysconf(_SC_PAGE_SIZE); // in case x86-64 is configured to use 2MB pages size_t rss = resident * page_size; diff --git a/src/slic3r/GUI/DesktopIntegrationDialog.cpp b/src/slic3r/GUI/DesktopIntegrationDialog.cpp index f0db5571d7..b05bf31241 100644 --- a/src/slic3r/GUI/DesktopIntegrationDialog.cpp +++ b/src/slic3r/GUI/DesktopIntegrationDialog.cpp @@ -208,7 +208,7 @@ bool copy_icon(const std::string& icon_path, const std::string& dest_path) bool create_desktop_file(const std::string& path, const std::string& data) { BOOST_LOG_TRIVIAL(debug) <<".desktop to "<< path; - std::ofstream output(path); + boost::nowide::ofstream output(path); output << data; struct stat buffer; if (stat(path.c_str(), &buffer) == 0) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 8f02788d8b..cad697ff0f 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -908,9 +908,9 @@ bool GUI_App::init_opengl() } // gets path to PrusaSlicer.ini, returns semver from first line comment -static boost::optional parse_semver_from_ini(std::string path) +static boost::optional parse_semver_from_ini(const std::string& path) { - std::ifstream stream(path); + boost::nowide::ifstream stream(path); std::stringstream buffer; buffer << stream.rdbuf(); std::string body = buffer.str(); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp index 8e27d4d1f7..54e601e850 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp @@ -1594,18 +1594,14 @@ void GLGizmoSVG::draw_filename(){ wxFileDialog dlg(parent, dlg_title, last_used_directory, dlg_file, wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT); if (dlg.ShowModal() == wxID_OK ){ last_used_directory = dlg.GetDirectory(); - wxString out_path = dlg.GetPath(); - //Slic3r::save(*m_volume_shape.svg_file.image, out_path.ToUTF8().data()); - - // Be carefull out_path_str is not UTF8 on purpose - storing into not ut6 filepath - std::string out_path_str(out_path.c_str()); - std::ofstream stream(out_path_str); + std::string out_path_str(into_u8(dlg.GetPath())); + boost::nowide::ofstream stream(out_path_str); if (stream.is_open()){ stream << *svg.file_data; // change source file m_filename_preview.clear(); - m_volume_shape.svg_file->path = out_path.ToUTF8().data(); + m_volume_shape.svg_file->path = out_path_str; m_volume_shape.svg_file->path_in_3mf.clear(); // possible change name m_volume->emboss_shape->svg_file = m_volume_shape.svg_file; // copy - write changes into volume } else { diff --git a/src/slic3r/GUI/PresetArchiveDatabase.cpp b/src/slic3r/GUI/PresetArchiveDatabase.cpp index f011b91d53..ac94a7f6b8 100644 --- a/src/slic3r/GUI/PresetArchiveDatabase.cpp +++ b/src/slic3r/GUI/PresetArchiveDatabase.cpp @@ -514,7 +514,7 @@ void PresetArchiveDatabase::load_app_manifest_json() if (!fs::exists(path, ec) || ec) { copy_initial_manifest(); } - std::ifstream file(path.string()); + boost::nowide::ifstream file(path.string()); std::string data; if (file.is_open()) { std::string line; @@ -681,7 +681,7 @@ void PresetArchiveDatabase::save_app_manifest_json() const data += "]"; std::string path = get_stored_manifest_path().string(); - std::ofstream file(path); + boost::nowide::ofstream file(path); if (file.is_open()) { file << data; file.close(); diff --git a/src/slic3r/Utils/Http.cpp b/src/slic3r/Utils/Http.cpp index 21de6b4ec1..978e91b5ec 100644 --- a/src/slic3r/Utils/Http.cpp +++ b/src/slic3r/Utils/Http.cpp @@ -301,7 +301,7 @@ void Http::priv::form_add_file(const char *name, const fs::path &path, const cha //FIXME may throw! Is the caller aware of it? void Http::priv::set_post_body(const fs::path &path) { - std::ifstream file(path.string()); + boost::nowide::ifstream file(path.string()); std::string file_content { std::istreambuf_iterator(file), std::istreambuf_iterator() }; postfields = std::move(file_content); }