def _get_char(self, win, char):
        def get_check_next_byte():
            char = win.getch()
            if 128 <= char <= 191:
                return char
            else:
                raise UnicodeError

        bytes = []
        if char <= 127:
            # 1 bytes
            bytes.append(char)
        #elif 194 <= char <= 223:
        elif 192 <= char <= 223:
            # 2 bytes
            bytes.append(char)
            bytes.append(get_check_next_byte())
        elif 224 <= char <= 239:
            # 3 bytes
            bytes.append(char)
            bytes.append(get_check_next_byte())
            bytes.append(get_check_next_byte())
        elif 240 <= char <= 244:
            # 4 bytes
            bytes.append(char)
            bytes.append(get_check_next_byte())
            bytes.append(get_check_next_byte())
            bytes.append(get_check_next_byte())
        #print('bytes = {}'.format(bytes))
        """ no zero byte allowed """
        while 0 in bytes:
            bytes.remove(0)
        if version_info < (3, 0):
            out = ''.join([chr(b) for b in bytes])
        else:
            buf = bytearray(bytes)
            out = self._decode_string(buf)
            #out = buf.decode('utf-8')
        return out
def _get_char ( self , win , char ) : def get_check_next_byte ( ) : char = win . getch ( ) if 128 <= char <= 191 : return char else : raise UnicodeError bytes = [ ] if char <= 127 : bytes . append ( char ) elif 192 <= char <= 223 : bytes . append ( char ) bytes . append ( get_check_next_byte ( ) ) elif 224 <= char <= 239 : bytes . append ( char ) bytes . append ( get_check_next_byte ( ) ) bytes . append ( get_check_next_byte ( ) ) elif 240 <= char <= 244 : bytes . append ( char ) bytes . append ( get_check_next_byte ( ) ) bytes . append ( get_check_next_byte ( ) ) bytes . append ( get_check_next_byte ( ) ) """ no zero byte allowed """ while 0 in bytes : bytes . remove ( 0 ) if version_info < ( 3 , 0 ) : out = '' . join ( [ chr ( b ) for b in bytes ] ) else : buf = bytearray ( bytes ) out = self . _decode_string ( buf ) return out
no zero byte allowed