Re: Characters Being Misread

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michiel Overtoom

    Re: Characters Being Misread

    Victor wrote...
    >>>import binascii
    >>>binascii.unh exlify('\x0c')
    >TypeError: Odd-length string
    >What gives here?
    The function unhexlify() wants an even-length string. From the online help:
    >>help(binascii .unhexlify)
    unhexlify(...)
    a2b_hex(hexstr) -s; Binary data of hexadecimal representation.
    hexstr must contain an even number of hex digits (upper or lower case).
    This function is also available as "unhexlify( )"

    And you use it like this:
    >>binascii.unhe xlify("41")
    'A'


    You feed it data without any '0x' prefixes.

    What are you trying to do? Parsing an RTF file which contains unicode
    characerts, encoded as hexadecimal?

    Greetings,


    --
    "The ability of the OSS process to collect and harness
    the collective IQ of thousands of individuals across
    the Internet is simply amazing." - Vinod Vallopillil


Working...