CharacterSet

Members

Static functions

convert
string convert(string str, string toCodeset, string fromCodeset, size_t bytesRead)

Converts a string from one character set to another.

convertErrorQuark
GQuark convertErrorQuark()
convertWithFallback
string convertWithFallback(string str, string toCodeset, string fromCodeset, string fallback, size_t bytesRead)

Converts a string from one character set to another, possibly including fallback sequences for characters not representable in the output. Note that it is not guaranteed that the specification for the fallback sequences in @fallback will be honored. Some systems may do an approximate conversion from @from_codeset to @to_codeset in their iconv() functions, in which case GLib will simply return that approximate conversion.

convertWithIconv
string convertWithIconv(string str, GIConv converter, size_t bytesRead)

Converts a string from one character set to another.

filenameDisplayBasename
string filenameDisplayBasename(string filename)

Returns the display basename for the particular filename, guaranteed to be valid UTF-8. The display name might not be identical to the filename, for instance there might be problems converting it to UTF-8, and some files can be translated in the display.

filenameDisplayName
string filenameDisplayName(string filename)

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.

filenameFromUtf8
string filenameFromUtf8(string utf8string, ptrdiff_t len, size_t bytesRead, size_t bytesWritten)

Converts a string from UTF-8 to the encoding GLib uses for filenames. Note that on Windows GLib uses UTF-8 for filenames; on other platforms, this function indirectly depends on the [current locale]setlocale.

filenameToUtf8
string filenameToUtf8(string opsysstring, ptrdiff_t len, size_t bytesRead, size_t bytesWritten)

Converts a string which is in the encoding used by GLib for filenames into a UTF-8 string. Note that on Windows GLib uses UTF-8 for filenames; on other platforms, this function indirectly depends on the [current locale]setlocale.

getCharset
bool getCharset(string charset)

Obtains the character set for the [current locale]setlocale; you might use this character set as an argument to g_convert(), to convert from the current locale's encoding to some other encoding. (Frequently g_locale_to_utf8() and g_locale_from_utf8() are nice shortcuts, though.)

getCodeset
string getCodeset()

Gets the character set for the current locale.

getConsoleCharset
bool getConsoleCharset(string charset)

Obtains the character set used by the console attached to the process, which is suitable for printing output to the terminal.

getFilenameCharsets
bool getFilenameCharsets(string[] filenameCharsets)

Determines the preferred character sets used for filenames. The first character set from the @charsets is the filename encoding, the subsequent character sets are used when trying to generate a displayable representation of a filename, see g_filename_display_name().

getLanguageNamesWithCategory
string[] getLanguageNamesWithCategory(string categoryName)

Computes a list of applicable locale names with a locale category name, which can be used to construct the fallback locale-dependent filenames or search paths. The returned list is sorted from most desirable to least desirable and always contains the default locale "C".

localeFromUtf8
string localeFromUtf8(string utf8string, ptrdiff_t len, size_t bytesRead)

Converts a string from UTF-8 to the encoding used for strings by the C runtime (usually the same as that used by the operating system) in the [current locale]setlocale. On Windows this means the system codepage.

localeToUtf8
string localeToUtf8(string opsysstring, size_t bytesRead, size_t bytesWritten)

Converts a string which is in the encoding used for strings by the C runtime (usually the same as that used by the operating system) in the [current locale]setlocale into a UTF-8 string.

Meta