remove nonprintable chars
This commit is contained in:
parent
d161275465
commit
f540b9658d
@ -96,6 +96,7 @@ class driver():
|
|||||||
self.env['screenData']['newCursor']['y'] = int( self.env['screenData']['newContentBytes'][3])
|
self.env['screenData']['newCursor']['y'] = int( self.env['screenData']['newContentBytes'][3])
|
||||||
# analyze content
|
# 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'] = 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']['newContentAttrib'] = self.env['screenData']['newContentBytes'][5:][::2]
|
||||||
self.env['screenData']['newContentText'] = screen_utils.insertNewlines(self.env['screenData']['newContentText'], self.env['screenData']['columns'])
|
self.env['screenData']['newContentText'] = screen_utils.insertNewlines(self.env['screenData']['newContentText'], self.env['screenData']['columns'])
|
||||||
|
|
||||||
|
@ -6,6 +6,13 @@
|
|||||||
|
|
||||||
from core import debug
|
from core import debug
|
||||||
from collections import Counter
|
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):
|
def insertNewlines(string, every=64):
|
||||||
return '\n'.join(string[i:i+every] for i in range(0, len(string), every))
|
return '\n'.join(string[i:i+every] for i in range(0, len(string), every))
|
||||||
|
Loading…
Reference in New Issue
Block a user