wc3270 Error UnicodeDecodeError: 'utf8' after change language

120 views
Skip to first unread message

setthapong imsuwan

unread,
Aug 28, 2019, 6:17:51 AM8/28/19
to BlazeLibs
Hi Team,

     I change language setting to  wc3270.charset: thai

class wc3270App(ExecutableAppWin):
executable = 'wc3270'
args = ['-xrm', 'wc3270.unlockDelay: False', '-xrm', 'wc3270.model: 2', '-xrm', 'wc3270.charset: thai']

   and use keyword read, Page should contain string Error 

UnicodeDecodeError: 'utf8' codec can't decode byte 0xc8 in position 12: invalid continuation byte

   What did i do wrong 

STaRNiGHT

unread,
Aug 28, 2019, 6:30:42 AM8/28/19
to BlazeLibs
Hi, i found similar problem in Spanish characters.

em = Emulator(visible=EmuladorVisible, timeout=30, app=None, args=["-model", "3279-2", "-charset", "spanish-euro"])



The only way I have found to solve it is by modifying the library ... I know it's not a very "elegant" solution but I didn't find another way

lines 413 and 455 from file __init__.py modify enconding from "ascii" to "latin-1" in my case

413 self.exec_command('String("{0}")'.format(tosend).encode("latin-1"))
455 return cmd.data[0].decode("latin-1")


It has worked for me, I have been using the modified library for almost a year without problems

Regards

setthapong imsuwan

unread,
Aug 29, 2019, 12:45:05 AM8/29/19
to BlazeLibs
Ok Thank you STaRNiGHT 

          I try this

เมื่อ วันพุธที่ 28 สิงหาคม ค.ศ. 2019 17 นาฬิกา 30 นาที 42 วินาที UTC+7, STaRNiGHT เขียนว่า:

setthapong imsuwan

unread,
Aug 30, 2019, 12:37:30 AM8/30/19
to BlazeLibs
Hi STaRNiGHT

         Thank you for support. 
   
          I edit function string_get follow this code

cmd = self.exec_command('ascii({0},{1},{2})'.format(ypos, xpos, length).encode("ascii"))
# this usage of utf-8 should only return a single line of data
assert len(cmd.data) == 1, cmd.data
buildin_str = _Converter()
string_str = String()
str_r = cmd.data[0]
str_byte = buildin_str.convert_to_bytes(str_r)
str_uni = string_str.decode_bytes_to_string(str_byte, "ISO-8859-11")
return str_uni

        this way is working for me.      

         


เมื่อ วันพุธที่ 28 สิงหาคม ค.ศ. 2019 17 นาฬิกา 30 นาที 42 วินาที UTC+7, STaRNiGHT เขียนว่า:
Hi, i found similar problem in Spanish characters.
Reply all
Reply to author
Forward
0 new messages