iTunes Crashing on Import

I wrote an application to migrate ratings from the Windows Media Player XML export format into an iTunes Music Library XML file.

I got hung up on one problem: iTunes would crash on import. Investigating, I discovered that all I had to do to get iTunes to crash was open the "iTunes Music Library.xml" with Notepad, and save it. Trying to import the 'unmodified' file would crash iTunes.

Looking at a hex dump of the files, there was one difference. The file that crashed iTunes had a byte-order-mark at the start of the file, signifying that it was a UTF-8 file. Apparently the XML reader in iTunes doesn't understand this and blows up.

Loading the exported file that crashes iTunes into Visual Studio, and saving it as UTF-8 Without Signature makes it importable into iTunes.

This is iTunes 4.7.