Locale information

Locale information — Information about languages, character sets etc.

Functions

Properties

gchar * charset Read / Write / Construct Only
gboolean is-utf8 Read / Write / Construct Only
gchar * requested-name Read / Write / Construct Only
gchar * resulting-name Read / Write / Construct Only

Types and Values

Object Hierarchy

    GEnum
    ╰── SrtLocaleError
    GFlags
    ╰── SrtLocaleIssues
    GObject
    ╰── SrtLocale

Includes

#include <steam-runtime-tools/steam-runtime-tools.h>

Description

SrtLocale is an opaque object representing a locale. This is a reference-counted object: use g_object_ref() and g_object_unref() to manage its lifecycle.

Functions

SRT_LOCALE_ERROR

#define SRT_LOCALE_ERROR (srt_locale_error_quark ())

srt_locale_error_quark ()

GQuark
srt_locale_error_quark (void);

srt_locale_get_requested_name ()

const char *
srt_locale_get_requested_name (SrtLocale *self);

Return the name of the locale that was checked.

Parameters

self

a locale object

 

srt_locale_get_resulting_name ()

const char *
srt_locale_get_resulting_name (SrtLocale *self);

Return the name of the locale that was actually set when “requested-name” was requested. For example, if “requested-name” is POSIX, the locale that is actually set will typically be named C.

Parameters

self

a locale object

 

srt_locale_get_charset ()

const char *
srt_locale_get_charset (SrtLocale *self);

Return the character set used by the locale, hopefully UTF-8.

Parameters

self

a locale object

 

Returns

“charset”


srt_locale_is_utf8 ()

gboolean
srt_locale_is_utf8 (SrtLocale *self);

Return TRUE if the locale appears to be a UTF-8 locale. For example, C.UTF-8 and en_US.UTF-8 are UTF-8 locales, but C and en_US are typically not.

Parameters

self

a locale object

 

Returns

“is-utf8”

Types and Values

enum SrtLocaleError

Errors in this domain indicate that problems were encountered when setting or inspecting a locale.

Members

SRT_LOCALE_ERROR_FAILED

Unable to set the locale

 

SRT_LOCALE_ERROR_INTERNAL_ERROR

Unable to check whether the locale could be set or not

 

SRT_LOCALE_ISSUES_INTERNAL_ERROR

#define SRT_LOCALE_ISSUES_INTERNAL_ERROR SRT_LOCALE_ISSUES_UNKNOWN

enum SrtLocaleIssues

A bitfield with flags representing potential problems with locales, or SRT_LOCALE_ISSUES_NONE (which is numerically zero) if no problems were detected.

In general, more bits set means more problems, with the only exception for SRT_LOCALE_ISSUES_UNKNOWN.

Members

SRT_LOCALE_ISSUES_NONE

There are no problems

 

SRT_LOCALE_ISSUES_UNKNOWN

An internal error of some kind has occurred, or an unknown issue flag was encountered while reading a report.

 

SRT_LOCALE_ISSUES_DEFAULT_MISSING

setlocale (LC_ALL, "") fails. This indicates that environment variables like LANGUAGE and LC_ALL are set to values that do not match the locales available on the filesystem.

 

SRT_LOCALE_ISSUES_DEFAULT_NOT_UTF8

setlocale (LC_ALL, "") succeeds but results in a a non-UTF-8 locale. This often breaks program and library assumptions, particularly around interoperable filenames.

 

SRT_LOCALE_ISSUES_C_UTF8_MISSING

setlocale (LC_ALL, "C.UTF-8") does not succeed, or succeeds but results in a non-UTF-8 locale. This locale is available in Debian and Fedora derivatives, and is a UTF-8 equivalent of the standard C/POSIX locale. It has been proposed for inclusion in upstream glibc, but as of 2019 it is not available on all Linux systems.

 

SRT_LOCALE_ISSUES_EN_US_UTF8_MISSING

setlocale (LC_ALL, "en_US.UTF-8") does not succeed, or succeeds but results in a non-UTF-8 locale. This locale is not generally guaranteed to exist on Linux systems, but some games and software packages assume that it does.

 

SRT_LOCALE_ISSUES_I18N_SUPPORTED_MISSING

The SUPPORTED file listing supported locales was not found in the expected location. This indicates that either locale data is not installed, or this operating system does not put it in the expected location. The Steam Runtime might be unable to generate extra locales if needed.

 

SRT_LOCALE_ISSUES_I18N_LOCALES_EN_US_MISSING

The locales/en_US file describing the USA English locale was not found in the expected location. This indicates that either locale data is not installed, or this operating system does not put it in the expected location, or only a partial set of locale source data is available. The Steam Runtime will be unable to generate extra locales if needed.

 

Property Details

The “charset” property

  “charset”                  gchar *

The name of a character set, typically UTF-8.

Flags: Read / Write / Construct Only

Default value: NULL


The “is-utf8” property

  “is-utf8”                  gboolean

TRUE if the character set is UTF-8.

Flags: Read / Write / Construct Only

Default value: FALSE


The “requested-name” property

  “requested-name”           gchar *

The locale name that was checked.

Flags: Read / Write / Construct Only

Default value: NULL


The “resulting-name” property

  “resulting-name”           gchar *

The locale name that was the result of calling setlocale().

Flags: Read / Write / Construct Only

Default value: NULL