vdaron / MusicXml.Net

Quick C# parser for MusicXML
Other
58 stars 27 forks source link

Text Encoding Support #15

Open oxygen-dioxide opened 1 year ago

oxygen-dioxide commented 1 year ago

Added GetScore(string filename, System.Text.Encoding encoding) that allows the user to load the musicxml file in a certain text encoding, such as GBK or ShiftJIS.

Tests for text encodings are added into the repo. The test data is Joseph Haydn's Emperor Quartet in simplified Chinese and Japanese.

vdaron commented 1 year ago

Hi Oxygen-Dioxide

You where right, the Encoding was not correctly handled while loading XML.

The encoding of the file is specified in the xml header and it's taken into account by XmlDocument.Load(). I just fixed the load of XmlDocument to use the correct encoding. When loading an XML file you should not have to specify the encoding, it must be detected automatically.

Unfortunately, it seems that it's not the case of you sample files (the encoding specified is UTF-8 even if the lyrics contains non UTF-8 encoded text). I test your files using two MusicXML applications, Musescore and Pizzicato and they can't open them because of this. If I change the encoding in the XML file, the file can be loaded, but I can't say if the text is encoded correctly and the unit test are failing. Could you give it a try ?

Thanks

PS: Need to work my understanding of Chinese and Japanese, maybe for my next life :-)