/* Returns: If the conversion was successful, a newly allocated nul-terminated string, which must be freed with g_free(). Otherwise NULL and @error will be set.  */
gchar* g_convert(const gchar *str, gssize len, const gchar *to_codeset, const gchar *from_codeset, gsize *bytes_read, gsize *bytes_written, GError **error)
/* Returns: If the conversion was successful, a newly allocated nul-terminated string, which must be freed with g_free(). Otherwise NULL and @error will be set.  */
gchar* g_convert(const gchar *str, gssize len, const gchar *to_codeset, const gchar *from_codeset, gsize *bytes_read, gsize *bytes_written, GError **error)
{
  gchar *res;
  GIConv cd;
  g_return_val_if_fail (str != NULL, NULL);
  g_return_val_if_fail (to_codeset != NULL, NULL);
  g_return_val_if_fail (from_codeset != NULL, NULL);
  cd = open_converter (to_codeset, from_codeset, error);
  if (cd == (GIConv) -1)
    {
      if (bytes_read)
        *bytes_read = 0;
      if (bytes_written)
        *bytes_written = 0;
      return NULL;
    }
  res = g_convert_with_iconv (str, len, cd,
			      bytes_read, bytes_written,
			      error);
  close_converter (cd);
  return res;
}