gchar *url_encode(char *str) { gchar *coded; char *p; coded = gnome_vfs_escape_path_string(str); p = coded; while(p) { p = strchr(coded, '%'); if (p) *p = '_'; } return coded; }
/** * get_filename_on_disk_encoding * * if gnome_vfs is defined, this function will also escape local paths * to make sure we can open files with a # in their name */ gchar *get_filename_on_disk_encoding(const gchar *utf8filename) { if (utf8filename) { GError *gerror=NULL; gsize b_written; gchar *ondiskencoding = g_filename_from_utf8(utf8filename,-1, NULL,&b_written,&gerror); if (gerror) { g_print(_("Bluefish has trouble reading the filenames. Try to set the environment variable G_BROKEN_FILENAMES=1\n")); ondiskencoding = g_strdup(utf8filename); } #ifdef HAVE_GNOME_VFS /* convert local path's */ if (ondiskencoding[0] == '/') { gchar *tmp = gnome_vfs_escape_path_string(ondiskencoding); g_free(ondiskencoding); ondiskencoding = tmp; } #endif /* HAVE_GNOME_VFS */ return ondiskencoding; } return NULL; }