Skip to content

Commit

Permalink
fixes decoding cp1251 text (found in comments)
Browse files Browse the repository at this point in the history
  • Loading branch information
klensy committed Jul 19, 2018
1 parent f95d328 commit 3bd82c5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion blk_unpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,15 @@ def get_block_value(self, id_offset: int, block_type: int) -> Tuple[Any, int]:

def print_item(self, item_type: str, item_data, sub_units_names):
if item_type == 'str':
return sub_units_names[item_data].decode("utf-8")
s = sub_units_names[item_data]
try:
return s.decode("utf-8")
except UnicodeDecodeError as e: # russian win encoding
return s.decode("cp1251")
except Exception as e:
import sys
from traceback import print_exc
print_exc(file=sys.stdout)

This comment has been minimized.

Copy link
@klensy

klensy Jul 19, 2018

Author Owner

Should break decoding of entire blk or return some placeholder?

elif item_type == 'float':
return float('%.4f' % item_data)
elif item_type == 'bool':
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

setup(
name="wt-tools",
version="0.2.1.2-dev",
version="0.2.1.3-dev",
author='klensy',
description="War Thunder resource extraction tools",
options={"build_exe": {"includes": includes, "excludes": excludes, "include_files": includefiles,
Expand Down

0 comments on commit 3bd82c5

Please sign in to comment.