This PR fixes an issue with reading some compressed MusicXML files. Two example files are MozaChloSample and MozaVeilSample from this example set (these files also seem to be available in the regression test repository). Uncompressed versions of these files are opened fine but compressed .mxl files cannot be loaded by Lomse.
The reason of the issue is that the implementation in #246 loads unzipped XML code via MxlCompiler::compile_string() function which internally calls load_string() function from pugixml which assumes the string is already encoded in UTF-8. However the example scores listed above use UTF-16 encoding which is incompatible with UTF-8. File loading functions in pugixml do not assume any encoding by default and perform encoding detection which is why the uncompressed versions of the example scores are loaded correctly.
The issue can be fixed by using pugixml's load_buffer() which takes an in-memory buffer as input and doesn't skip encoding detection. This solution is implemented in this pull request. After this patch any encoding supported by pugixml should work fine with both compressed and uncompressed MusicXML files.
This PR fixes an issue with reading some compressed MusicXML files. Two example files are
MozaChloSample
andMozaVeilSample
from this example set (these files also seem to be available in the regression test repository). Uncompressed versions of these files are opened fine but compressed.mxl
files cannot be loaded by Lomse.The reason of the issue is that the implementation in #246 loads unzipped XML code via
MxlCompiler::compile_string()
function which internally callsload_string()
function from pugixml which assumes the string is already encoded in UTF-8. However the example scores listed above use UTF-16 encoding which is incompatible with UTF-8. File loading functions in pugixml do not assume any encoding by default and perform encoding detection which is why the uncompressed versions of the example scores are loaded correctly.The issue can be fixed by using pugixml's
load_buffer()
which takes an in-memory buffer as input and doesn't skip encoding detection. This solution is implemented in this pull request. After this patch any encoding supported by pugixml should work fine with both compressed and uncompressed MusicXML files.