gdb/
[deliverable/binutils-gdb.git] / gdb / python / python-utils.c
index 6a959397b60c1bf55718c4454e4adaf0c82cd68c..b0ec7b3401505472271198729452194a6ed78349 100644 (file)
@@ -160,6 +160,19 @@ python_string_to_host_string (PyObject *obj)
   return unicode_to_encoded_string (str, host_charset ());
 }
 
+/* Converts a target string of LENGTH bytes in the target's charset to a
+   Python Unicode string. If LENGTH is -1, convert until a null byte is found.
+
+   Returns NULL on error, with a python exception set.  */
+PyObject *
+target_string_to_unicode (const gdb_byte *str, int length)
+{
+  if (length == -1)
+    length = strlen (str);
+
+  return PyUnicode_Decode (str, length, target_charset (), NULL);
+}
+
 /* Return true if OBJ is a Python string or unicode object, false
    otherwise.  */
 
This page took 0.023609 seconds and 4 git commands to generate.