/* Returns: TRUE if the returned charset is UTF-8  */
gboolean g_get_charset(const char **charset)
/* Returns: TRUE if the returned charset is UTF-8  */
gboolean g_get_charset(const char **charset)
{
  static GPrivate cache_private = G_PRIVATE_INIT (charset_cache_free);
  GCharsetCache *cache = g_private_get (&cache_private);
  const gchar *raw;
  if (!cache)
    {
      cache = g_new0 (GCharsetCache, 1);
      g_private_set (&cache_private, cache);
    }
  G_LOCK (aliases);
  raw = _g_locale_charset_raw ();
  G_UNLOCK (aliases);
  if (!(cache->raw && strcmp (cache->raw, raw) == 0))
    {
      const gchar *new_charset;
      g_free (cache->raw);
      g_free (cache->charset);
      cache->raw = g_strdup (raw);
      cache->is_utf8 = g_utf8_get_charset_internal (raw, &new_charset);
      cache->charset = g_strdup (new_charset);
    }
  if (charset)
    *charset = cache->charset;
  return cache->is_utf8;
}