docrecord: avoid UnicodeEncodeError on non-utf8 terminals

As reported by Tor Lillqvist.