GNOME Bugzilla – Bug 542058
g_get_user_name
Last modified: 2018-05-24 11:29:02 UTC
The output of g_get_user_name is so ill defined that none of the callers that I located via google use it right. I would guess that no-one is. There ought to be one or more wrappers that allow applications to use it right. There seem to be two classes of uses: 1. UTF-8 for display. Here's one from Nautilus: return g_strdup_printf (_("%s's Home"), g_get_user_name ()); A variant for this should validate for UTF-8 and convert/transscribe to UTF-8 for anything that isn't. 2. For filenames. Here's one from Gimp 2.3.18: gchar *user_name = g_strdup (g_get_user_name ()); ... subdir_name = g_strconcat (GIMPDIR ".", user_name, NULL); A variant for this should ensure that the encoding is right for filenames and that no invalid characters occur in the name. Gimp tries to do that for Win32, but does not get it right. (Also, the docs for g_get_user_name fail to mention that while the encoding uses is undefined, it is an encoding that uses zero termination.)
Created attachment 155970 [details] [review] g_get_user_name_for_display This function handles the display case.
Created attachment 163799 [details] [review] Implement g_get_user_name_for_display
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/149.