-
-
Notifications
You must be signed in to change notification settings - Fork 48
Open
Description
Hey! I've been using pymem lately and found out that I can't read any UTF-16 strings.
Let's take a look at this byte's representation of Hello string:
UTF-8
0x48 0x65 0x6C 0x6C 0x6F
UTF-16-LE
0x48 0x00 0x65 0x00 0x6C 0x00 0x6C 0x00 0x6F 0x00
As you can see there is empty bytes added in UTF-16 strings and that's how things work, but current solution probably breaks, because of these empty appended bytes:
def read_string(handle, address, byte=50, encoding='UTF-8'):
buff = read_bytes(handle, address, byte)
i = buff.find(b'\x00')
if i != -1:
buff = buff[:i]
buff = buff.decode(encoding)
return buffMay be we can ignore this truncation for UTF-16, what you guys think?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels