Skip to content

Commit

Permalink
Alternative approach, fix the write at the source
Browse files Browse the repository at this point in the history
  • Loading branch information
Jojo-Schmitz committed Apr 23, 2024
1 parent 9e939b2 commit bdab1b0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/engraving/dom/chordlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1784,8 +1784,7 @@ void ChordList::write(XmlWriter& xml) const
if (s.code.isNull()) {
xml.tag("sym", { { "name", s.name }, { "value", s.value } });
} else {
// write hex numbers with a "0x" prefix, so they can convert back properly on read
xml.tag("sym", { { "name", s.name }, { "code", u"0x" + String::number(s.code.unicode(), 16) } });
xml.tag("sym", { { "name", s.name }, { "code", String::number(s.code.unicode(), 16) } });
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/dom/page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ String Page::replaceTextMacros(const String& s) const
} else {
int rev = score()->mscoreRevision();
if (rev > 99999) { // MuseScore 1.3 is decimal 5702, 2.0 and later uses a 7-digit hex SHA
d += String::number(rev, 16);
d += String::number(rev, 16).remove(u"0x");
} else {
d += String::number(rev, 10);
}
Expand Down
17 changes: 14 additions & 3 deletions src/framework/global/types/string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1265,11 +1265,22 @@ unsigned int String::toUInt(bool* ok, int base) const
String String::number(int n, int base)
{
std::stringstream stream;
if (base == 16) {
stream << std::hex;
switch (base) {
case 16: stream << std::hex;
break;
case 10: stream << std::dec;
break;
case 8: stream << std::oct;
break;
}
stream << n;
std::string s = stream.str();
std::string s = stream.str();
switch (base) {
case 16: s = "0x" + s;
break;
case 8: s = "0" + s;
break;
}
return fromAscii(s.c_str(), s.size());
}

Expand Down

0 comments on commit bdab1b0

Please sign in to comment.