GLib.filename_display_name

function filename_display_name(filename: String): String {
    // Gjs wrapper for g_filename_display_name()
}
  

Converts a filename into a valid UTF-8 string. The conversion is not necessarily reversible, so you should keep the original around and use the return value of this function only for display purposes. Unlike GLib.filename_to_utf8, the result is guaranteed to be non-null even if the filename actually isn't in the GLib file name encoding.

If GLib cannot make sense of the encoding of filename, as a last resort it replaces unknown characters with U+FFFD, the Unicode replacement character. You can search the result for the UTF-8 encoding of this character (which is "\357\277\275" in octal notation) to find out if filename was in an invalid encoding.

If you know the whole pathname of the file you should use GLib.filename_display_basename, since that allows location-based translation of filenames.

Since 2.6

filename

a pathname hopefully in the GLib file name encoding

Returns

a newly allocated string containing a rendition of the filename in valid UTF-8