Added fallback handling from utf-8 to latin1 when reading charter text files.
- Legacy-Id: 17126
This commit is contained in:
parent
d9c19449ce
commit
6f8263eb6e
|
@ -57,8 +57,13 @@ def get_charter_text(group):
|
|||
|
||||
filename = os.path.join(c.get_file_path(), "%s-%s.txt" % (c.canonical_name(), c.rev))
|
||||
try:
|
||||
with io.open(filename) as f:
|
||||
return f.read()
|
||||
with io.open(filename, 'rb') as f:
|
||||
text = f.read()
|
||||
try:
|
||||
text = text.decode('utf8')
|
||||
except UnicodeDecodeError:
|
||||
text = text.decode('latin1')
|
||||
return text
|
||||
except IOError:
|
||||
return 'Error Loading Group Charter'
|
||||
|
||||
|
|
Loading…
Reference in a new issue