CharacterSet.filenameDisplayName

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 g_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 g_filename_display_basename(), since that allows location-based translation of filenames.

struct CharacterSet
static
string
filenameDisplayName
(
string filename
)

Parameters

filename string

a pathname hopefully in the GLib file name encoding

Return Value

Type: string

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

Meta