GLib.utf8_collate_key_for_filename
function utf8_collate_key_for_filename(str: String, len: Number(gssize)): String { // Gjs wrapper for g_utf8_collate_key_for_filename() }
Converts a string into a collation key that can be compared with other collation keys produced by the same function using strcmp().
In order to sort filenames correctly, this function treats the dot '.' as a special case. Most dictionary orderings seem to consider it insignificant, thus producing the ordering "event.c" "eventgenerator.c" "event.h" instead of "event.c" "event.h" "eventgenerator.c". Also, we would like to treat numbers intelligently so that "file1" "file10" "file5" is sorted as "file1" "file5" "file10".
Note that this function depends on the [current locale][setlocale].
Since 2.8
- str
a UTF-8 encoded string.
- len
length of str, in bytes, or -1 if str is nul-terminated.
- Returns
a newly allocated string. This string should be freed with GLib.free when you are done with it.