1
Vote

Bug with ncx file creation and UTF8 text

description

When trying to create a book.ncx file that contains UTF8 text in it, the XML generation part works fine and creates the XMLDocument just fine. However, you write it directly to the zipfile with the file.AddEntity() command. This command is not preserving the UTF8 text (an Iconic.Zip library problem) but is putting in the file as ASCII. This corrupts the file and crashes most Epub readers that I tried it on.
 
A workaround to this bug is to first save the XMLDocument to disk and then add it in to the zip as a file rather than an entity. Code changes below for EpubBase.cs
 
    protected void GenerateMetadataAndTocFiles()
    {
        XmlDocument ncxfile = TableOfContents.BuildAndGetXmlDocument();
        string tempPath = System.IO.Path.GetTempPath() + "book.ncx";
        ncxfile.Save(tempPath);
        file.AddFile(tempPath, Structure.Directories.ContentFolder);
        //file.AddEntry(Structure.Files.NcxFileFullPath, TableOfContents.BuildAndGetContent());
        file.AddEntry(Structure.Files.OpfFileFullPath, Metadata.BuildAndGetContent());
    }

comments

dirkkaiser wrote Aug 23, 2012 at 7:56 AM

should also note that this bug was in 0.2. Haven't looked at your latest version with the newer zip library.

wrote Feb 13, 2013 at 8:37 PM