From 24cee54192e50654723ef5bfb3eea91c9389a34c Mon Sep 17 00:00:00 2001 From: Joachim Schmitz Date: Tue, 23 Apr 2024 14:26:48 +0200 Subject: [PATCH] Fix GH#16363: Accidentals in chord symbols rendered incorrectly when using custom XML file --- src/engraving/dom/chordlist.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/engraving/dom/chordlist.cpp b/src/engraving/dom/chordlist.cpp index 8ddcd824d94ca..176fa8a82950c 100644 --- a/src/engraving/dom/chordlist.cpp +++ b/src/engraving/dom/chordlist.cpp @@ -1685,8 +1685,13 @@ void ChordList::read(XmlReader& e) String code = e.attribute("code"); String symClass = e.attribute("class"); if (!code.empty()) { + int base = 0; // guess, based on content + if (!code.startsWith(u"0") && !(code.startsWith(u"&#") && code.endsWith(u";"))) { + // fix broken chord lists, see https://github.com/musescore/MuseScore/issues/16363 + base = 16; // force hex + } bool ok = true; - char32_t val = code.toUInt(&ok, 0); + char32_t val = code.toUInt(&ok, base); if (!ok) { cs.code = 0; cs.value = code; @@ -1780,7 +1785,8 @@ void ChordList::write(XmlWriter& xml) const if (s.code.isNull()) { xml.tag("sym", { { "name", s.name }, { "value", s.value } }); } else { - xml.tag("sym", { { "name", s.name }, { "code", String::number(s.code.unicode(), 16) } }); + // 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) } }); } } }