From 6e7ea480ffdaea334e2304af1b4f64c1e5eb71da Mon Sep 17 00:00:00 2001 From: Martin Landa Date: Sat, 27 Aug 2022 16:00:49 +0200 Subject: [PATCH] mkhtml: use UTF-8 for decoding git log messages --- tools/mkhtml.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/tools/mkhtml.py b/tools/mkhtml.py index a6028dc03af..5a736f60945 100644 --- a/tools/mkhtml.py +++ b/tools/mkhtml.py @@ -90,25 +90,18 @@ def fatal(message): ) -def _get_encoding(): - encoding = locale.getdefaultlocale()[1] - if not encoding: - encoding = 'UTF-8' - return encoding - - -def decode(bytes_): +def decode(bytes_, encoding='UTF-8'): """Decode bytes with default locale and return (unicode) string No-op if parameter is not bytes (assumed unicode string). :param bytes bytes_: the bytes to decode + :param str encoding: encoding """ if isinstance(bytes_, unicode): return bytes_ if isinstance(bytes_, bytes): - enc = _get_encoding() - return bytes_.decode(enc) + return bytes_.decode(encoding) return unicode(bytes_) @@ -355,7 +348,7 @@ def read_file(name): if PY2: return s else: - return decode(s) + return decode(s, encoding='ISO-8859-1') except IOError: return ""