Re: How to find out which default encoding is used
- From: Owen Taylor <otaylor redhat com>
- To: Alois Goller <goller tttech com>
- Cc: gtk-i18n-list gnome org
- Subject: Re: How to find out which default encoding is used
- Date: 28 Dec 2001 12:26:43 -0500
Alois Goller <goller tttech com> writes:
> What I actually would like to have is a function that returns the default
> encoding used. Any help or pointers are appreciated.
GLib-2.0 provides the function:
/**
* g_get_charset:
* @charset: return location for character set name
*
* Obtains the character set for the current locale; 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.)
*
* The return value is %TRUE if the locale's encoding is UTF-8, in that
* case you can perhaps avoid calling g_convert().
*
* The string returned in @charset is not allocated, and should not be
* freed.
*
* Return value: %TRUE if the returned charset is UTF-8
**/
gboolean g_get_charset (G_CONST_RETURN char **charset);
[ Note that the default assumption of GLib on Unix is that
filenames are stored in UTF-8, not the locale encoding --
so g_filename_to/from_utf8() are noops.
This comes from an opinion that storing untagged data
in a locale-specific encoding is a really bad idea. You
can override this by setting the G_BROKEN_FILENAMES
environment variable. ]
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]