g_get_user_name
Submitted by Morten Welinder
Link to original bug (#542058)
Description
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:
-
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.
-
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.)