/* Converts a python string (8-bit or unicode) to a target string in the host's charset. Returns NULL on error, with a python exception set. */ gdb::unique_xmalloc_ptr<char> python_string_to_host_string (PyObject *obj) { gdbpy_ref<> str (python_string_to_unicode (obj)); if (str == NULL) return NULL; return unicode_to_encoded_string (str.get (), host_charset ()); }
/* Converts a python string (8-bit or unicode) to a target string in the host's charset. Returns NULL on error, with a python exception set. The caller is responsible for xfree'ing the string. */ char * python_string_to_host_string (PyObject *obj) { PyObject *str; char *result; str = python_string_to_unicode (obj); if (str == NULL) return NULL; result = unicode_to_encoded_string (str, host_charset ()); Py_DECREF (str); return result; }
/* Returns a newly allocated string with the contents of the given unicode string object converted to the target's charset. If an error occurs during the conversion, NULL will be returned and a python exception will be set. */ gdb::unique_xmalloc_ptr<char> unicode_to_target_string (PyObject *unicode_str) { return unicode_to_encoded_string (unicode_str, target_charset (python_gdbarch)); }
/* Returns a newly allocated string with the contents of the given unicode string object converted to the target's charset. If an error occurs during the conversion, NULL will be returned and a python exception will be set. The caller is responsible for xfree'ing the string. */ char * unicode_to_target_string (PyObject *unicode_str) { return unicode_to_encoded_string (unicode_str, target_charset ()); }
/* Returns a newly allocated string with the contents of the given unicode string object converted to the target's charset. If an error occurs during the conversion, NULL will be returned and a python exception will be set. The caller is responsible for xfree'ing the string. */ char * unicode_to_target_string (PyObject *unicode_str) { return unicode_to_encoded_string (unicode_str, target_charset (python_gdbarch)); }