Skip to content

关于存在非UTF-8编码的字节序的报错 #1

@mitiandashuaibi

Description

@mitiandashuaibi

对于一些可能非UTF-8编码的字节序直接使用可能会报错,需要修改一下getProtobufPart函数
else: if IsType: return part_type, part_value.decode("utf-8") return part_value.decode("utf-8")
修改为
else: try: text = part_value.decode("utf-8") if IsType: return part_type, text return text except UnicodeDecodeError: if IsType: return part_type, binascii.hexlify(part_value).decode('utf-8') # Convert binary to hex string return binascii.hexlify(part_value).decode('utf-8')
即可

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions