I recently made a request to implement functionality for GLib, creating a title function just like it has in python. However, I was instructed by the maintainers to open a discussion here on the GNOME Discourse. I made a small implementation of this function, for me it works correctly. I would like to know if the community thinks it is viable to have this functionality in GLib, if the code I made is correct or needs improvement. Please leave your comments and criticisms on the subject, so that we can have feedback on the topic in question.
Sorry, I think that’s too specific to what a particular application would want (and also very hard to do correctly for every locale). If you can show that the same implementation of title casing would be useful for three or more applications (see CONTRIBUTING.md), then please re-open this issue. Thanks.
That response still stands — converting strings to title case is very use-case specific (why would an application want to do it; on what kind of strings; to produce what kind of title case) and would be hard to get working across multiple locales. Applications with specific use cases may be able to avoid that difficulty perhaps by ignoring non-Western-European locales (depending on their use case and target audience, I’m not advising it though). GLib can’t, so any implementation in GLib would have to do something appropriate for all locales.
To be clear, adding this functionality would need a very strongly evidence-backed proposal of how it would make several application authors’ lives easier, and would need to come with an implementation which can be shown to make sense for all locales.
Hello everyone, anyone can use this code if they want. In my case I have several input fields for the user, and I don’t want the data entered to look like this:
` my name is danilo.’ several blank spaces
This illustrates my point well: the code you’ve posted will actually generate the string My Name Is Danilo. (note the capitalised ‘Is’). Typically title case in English will keep short words and connectives (‘is’, ‘or’, ‘and’, etc.) in lowercase, though; and that’s where it becomes difficult to implement in a way that works for every locale and every use-case.
This kind of string manipulation is too specific to a single use-case to be in GLib.
This is imo a bit beyond the unicode functionality that glib can and should provide out of the box. We have case conversion and case properties for individual characters, and we have breaking properties. But the actual Unicode break algorithm (TR14) is implemented in pango.