Question of UTF16BE encoding / decoding
ur.liam at iksmlapan.reverse
Tue May 5 06:59:18 CEST 2009
I have an encoded string in the form "004e006100700061006c006d", if you
split on every 4 characters it decodes to a single character.
I have come up with this:
name = '004e006100700061006c006d'
name2 = ""
for x in range(0, len(name), 4):
name2 = name2 + chr(int(name[x:x+4], 16))
Is there a better way to do this using name.decode() that would then
also work with .encode()?
I have tried .decode("utf-16-be"), which I beleive is the format here,
but I am getting the error:
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-
11: ordinal not in range(128)
And my debugger seems to show a load of unicode when it breaks.
More information about the Python-list