Encoding bug when writing index (.hhk) file in HTML Help output

Xuerui Wang avatarXuerui Wang created an issue

I've been doing some documentation in Chinese recently, and with the language variable set to 'zh_CN' Sphinx works just fine. However, it failed to write my index file properly, throwing a UnicodeDecodeError. After examining the logfile the offending line was quickly located. It was sphinx/builders/htmlhelp.py:261, and the fix is something as simple as this:

def write_param(name, value):
    item = '    <param name="%s" value="%s">\n' % (name, value)
-   f.write(item.encode(self.encoding, 'xmlcharrefreplace'))
+   f.write(item)

The logfile is attached.

As a long-term solution, it would be best to write most of the built-in strings in Unicode literals, and to eliminate unneeded encoding/decoding calls.

Comments (3)

  1. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.