summaryrefslogtreecommitdiff
path: root/python/databuffer.py
diff options
context:
space:
mode:
authorJordan Wiens <github@psifertex.com>2025-09-26 15:55:40 -0400
committerJordan <github@psifertex.com>2025-10-01 15:19:28 -0400
commite69f1b5525b6bb6d8cd08849537dba890c016b93 (patch)
treeae7aa18206820c4199f5a948f43f42b0a396071c /python/databuffer.py
parent420d622f83ad687d5848211f52e2e21693a44a13 (diff)
better handling for when utf8 decoding fails
Diffstat (limited to 'python/databuffer.py')
-rw-r--r--python/databuffer.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/python/databuffer.py b/python/databuffer.py
index a54a6cc0..55b0f782 100644
--- a/python/databuffer.py
+++ b/python/databuffer.py
@@ -128,7 +128,10 @@ class DataBuffer:
data = core.BNGetDataBufferContents(self.handle)
assert data is not None, "core.BNGetDataBufferContents returned None"
ctypes.memmove(buf, data, len(self))
- return buf.raw.decode('utf8')
+ try:
+ return buf.raw.decode('utf8')
+ except UnicodeDecodeError:
+ return buf.raw.decode('charmap')
def __bytes__(self):
buf = ctypes.create_string_buffer(len(self))