FIX: fix saving wrong encoding to 3mf

Change-Id: Icebf770b3dde06216e427744de9377e3f0adda29
Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
Stone Li 2022-08-17 17:41:14 +08:00 committed by Lane.Wei
parent 5194e68ae4
commit 038a04175a
4 changed files with 67 additions and 27 deletions

View file

@ -1182,6 +1182,42 @@ std::string xml_escape(std::string text, bool is_marked/* = false*/)
return text;
}
std::string xml_unescape(std::string s)
{
std::string ret;
std::string::size_type i = 0;
std::string::size_type pos = 0;
while (i < s.size()) {
std::string rep;
if (s[i] == '&') {
if (s.substr(i, 4) == "&lt;") {
ret += s.substr(pos, i - pos) + "<";
i += 4;
pos = i;
}
else if (s.substr(i, 4) == "&gt;") {
ret += s.substr(pos, i - pos) + ">";
i += 4;
pos = i;
}
else if (s.substr(i, 5) == "&amp;") {
ret += s.substr(pos, i - pos) + "&";
i += 5;
pos = i;
}
else {
++i;
}
}
else {
++i;
}
}
ret += s.substr(pos);
return ret;
}
std::string format_memsize_MB(size_t n)
{
std::string out;