From 5e77691e7ec73a73b9aae80517592933540c3b3e Mon Sep 17 00:00:00 2001 From: Q Date: Sat, 30 Oct 2021 11:27:14 +0300 Subject: [PATCH] fix ascii codes --- reporting/ascii-codes.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/reporting/ascii-codes.py b/reporting/ascii-codes.py index e93be67..7f80c81 100755 --- a/reporting/ascii-codes.py +++ b/reporting/ascii-codes.py @@ -1,7 +1,10 @@ #!/usr/bin/env python3 import sys, os -sys.path.append(os.path.dirname(os.path.realpath(__file__))) +sys.path.append(os.path.join( + os.path.dirname(os.path.realpath(__file__)), + "..", "py-packages", "markslider", "markslider" +)) import ansicodes from argparse import ArgumentParser @@ -42,9 +45,14 @@ if __name__ == "__main__": table = [[] for x in range(8)] for c in range(0, 256): col = int(c / 32) - table[col].append( - (c, chr(c)) - ) + try: + table[col].append( + (c, chr(c).encode('latin1').decode(opts.cs)) + ) + except UnicodeDecodeError: + table[col].append( + (c, " ") + ) # sys.stdout.write(chr(c).decode('latin1')) # remove control chars table.pop(0)