Issues

Issue #693 resolved

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

Xuerui 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: {{{

!python

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 (5)

  1. Log in to comment