FIX: fix plate name encoding issue

Change-Id: Ia89b2c5bbb4519ed938ae23ff124719cfe6203de
Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
Stone Li 2023-06-20 11:54:31 +08:00 committed by Lane.Wei
parent 869a3046aa
commit 14cb2449c6
11 changed files with 45 additions and 55 deletions

View file

@ -2044,7 +2044,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
}
plate_data_list[it->first-1]->locked = it->second->locked;
plate_data_list[it->first-1]->plate_index = it->second->plate_index-1;
plate_data_list[it->first - 1]->plate_name = it->second->plate_name;
plate_data_list[it->first-1]->plate_name = it->second->plate_name;
plate_data_list[it->first-1]->obj_inst_map = it->second->obj_inst_map;
plate_data_list[it->first-1]->gcode_file = (m_load_restore || it->second->gcode_file.empty()) ? it->second->gcode_file : m_backup_path + "/" + it->second->gcode_file;
plate_data_list[it->first-1]->gcode_prediction = it->second->gcode_prediction;
@ -3831,7 +3831,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
m_curr_plater->plate_index = atoi(value.c_str());
}
else if (key == PLATER_NAME_ATTR) {
m_curr_plater->plate_name = xml_unescape(encode_path(value.c_str()));
m_curr_plater->plate_name = xml_unescape(value.c_str());
}
else if (key == LOCK_ATTR)
{
@ -6997,7 +6997,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
stream << " <" << PLATE_TAG << ">\n";
//plate index
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << PLATERID_ATTR << "\" " << VALUE_ATTR << "=\"" << plate_data->plate_index + 1 << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << PLATER_NAME_ATTR << "\" " << VALUE_ATTR << "=\"" << xml_escape(decode_path(plate_data->plate_name.c_str())) << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << PLATER_NAME_ATTR << "\" " << VALUE_ATTR << "=\"" << xml_escape(plate_data->plate_name.c_str()) << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << LOCK_ATTR << "\" " << VALUE_ATTR << "=\"" << std::boolalpha<< plate_data->locked<< "\"/>\n";
ConfigOption* bed_type_opt = plate_data->config.option("curr_bed_type");
t_config_enum_names bed_type_names = ConfigOptionEnum<BedType>::get_enum_names();

View file

@ -552,7 +552,7 @@ protected:
bool m_no_check = false;
// current plate name
std::string m_plate_name;
std::string m_plate_name; // utf8 string
// Callback to be evoked regularly to update state of the UI thread.
status_callback_type m_status_callback;

View file

@ -571,6 +571,19 @@ inline std::string get_bbl_remain_time_dhms(float time_in_secs)
bool bbl_calc_md5(std::string &filename, std::string &md5_out);
inline std::string filter_characters(const std::string& str, const std::string& filterChars)
{
std::string filteredStr = str;
auto removeFunc = [&filterChars](char ch) {
return filterChars.find(ch) != std::string::npos;
};
filteredStr.erase(std::remove_if(filteredStr.begin(), filteredStr.end(), removeFunc), filteredStr.end());
return filteredStr;
}
} // namespace Slic3r
#if WIN32