From a972bb3980e2fb36bba296fe380b470dbddded2b Mon Sep 17 00:00:00 2001 From: Christian Herdtweck Date: Wed, 31 Oct 2018 11:01:27 +0100 Subject: [PATCH] olemeta: ensure stdout can handle unicode --- oletools/olemeta.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/oletools/olemeta.py b/oletools/olemeta.py index 2c0badd..a759cb2 100644 --- a/oletools/olemeta.py +++ b/oletools/olemeta.py @@ -79,6 +79,7 @@ if not _parent_dir in sys.path: import olefile from oletools.thirdparty import xglob from oletools.thirdparty.tablestream import tablestream +from oletools.common import ensure_stdout_handles_unicode #=== MAIN ================================================================= @@ -88,13 +89,12 @@ def process_ole(ole): meta = ole.get_metadata() # console output with UTF8 encoding: - # It looks like we do not need the UTF8 codec anymore, both for Python 2 and 3 - console_utf8 = sys.stdout #codecs.getwriter('utf8')(sys.stdout) + ensure_stdout_handles_unicode() # TODO: move similar code to a function print('Properties from the SummaryInformation stream:') - t = tablestream.TableStream([21, 30], header_row=['Property', 'Value'], outfile=console_utf8) + t = tablestream.TableStream([21, 30], header_row=['Property', 'Value']) for prop in meta.SUMMARY_ATTRIBS: value = getattr(meta, prop) if value is not None: @@ -111,7 +111,7 @@ def process_ole(ole): print('') print('Properties from the DocumentSummaryInformation stream:') - t = tablestream.TableStream([21, 30], header_row=['Property', 'Value'], outfile=console_utf8) + t = tablestream.TableStream([21, 30], header_row=['Property', 'Value']) for prop in meta.DOCSUM_ATTRIBS: value = getattr(meta, prop) if value is not None: -- libgit2 0.21.4