Unrecognized character sequences
Greetings! I love the work you have done with birp. I have been toting around a jumble of half-polished Ruby scripts to accomplish similar things, but I'm very impressed with what you already have working in birp.
One thing I've run into is that sometimes I get errors and crashes from unrecognized characters as birp is translating from x3270 into Python, etc. For example:
Hitting Enter, any of the PF/PA keys, or Ctrl-u will record a transaction.
Traceback (most recent call last):
File "birp.py", line 544, in <module>
menu(em, history)
File "birp.py", line 469, in menu
interactive(em,history)
File "birp.py", line 206, in interactive
print screen.colorbuffer.decode("utf-16").encode("utf-8")
File "/usr/lib/python2.7/encodings/utf_16.py", line 16, in decode
return codecs.utf_16_decode(input, errors, True)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2219' in position 24: ordinal not in ran
So far, I am working around this with the following small change:
$ git diff
diff --git a/birp.py b/birp.py
index 0ffff33..006c591 100755
--- a/birp.py
+++ b/birp.py
@@ -203,7 +203,7 @@ def interactive(em,history):
logger('Enter entered',kind='info')
elif key == getch.KEY_CTRLr: # Ctrl-r print screen
screen = update_screen(em,screen)
- print screen.colorbuffer
+ print screen.colorbuffer.encode("ascii", "ignore")
logger('Screen refreshed',kind='info')
elif key == getch.KEY_CTRLu: # Ctrl-u manually push transaction
screen = update_screen(em,screen)
The same occurs when I save a screen as a transaction, and I'm not sure that just ignoring character transcription errors is the "right thing to do".
Have you run into this in your testing?
Thanks!
I haven't run into this before. I see you made other changes in the error output (print screen.colorbuffer.decode("utf-16").encode("utf-8") isn't currently in my version of birp). Can you give me an example of a screen that caused the error on the current version of birp in the repo?