diff --git a/src/fenrir/screenDriver/linux.py b/src/fenrir/screenDriver/linux.py index 954bed56..4c480412 100644 --- a/src/fenrir/screenDriver/linux.py +++ b/src/fenrir/screenDriver/linux.py @@ -96,6 +96,7 @@ class driver(): self.env['screenData']['newCursor']['y'] = int( self.env['screenData']['newContentBytes'][3]) # analyze content self.env['screenData']['newContentText'] = self.env['screenData']['newContentBytes'][4:][::2].decode(screenEncoding, "replace").encode('utf-8').decode('utf-8') + self.env['screenData']['newContentText'] = screen_utils.removeNonprintable(self.env['screenData']['newContentText']) self.env['screenData']['newContentAttrib'] = self.env['screenData']['newContentBytes'][5:][::2] self.env['screenData']['newContentText'] = screen_utils.insertNewlines(self.env['screenData']['newContentText'], self.env['screenData']['columns']) diff --git a/src/fenrir/utils/screen_utils.py b/src/fenrir/utils/screen_utils.py index 8efd4175..5de55a9d 100644 --- a/src/fenrir/utils/screen_utils.py +++ b/src/fenrir/utils/screen_utils.py @@ -6,6 +6,13 @@ from core import debug from collections import Counter +import string + +def removeNonprintable(text): + # Get the difference of all ASCII characters from the set of printable characters + nonprintable = set([chr(i) for i in range(128)]).difference(string.printable) + # Use translate to remove all non-printable characters + return text.translate({ord(character):None for character in nonprintable}) def insertNewlines(string, every=64): return '\n'.join(string[i:i+every] for i in range(0, len(string), every))