g_get_charset() thinks UTF-8 system is ASCII
I noticed g_print
was replacing non-ASCII but valid UTF-8 characters with question marks, while printf
displayed them correctly, so I wrote a quick test. When I compile and run the code below on Arch Linux it prints:
Charset is 'ANSI_X3.4-1968' (not UTF)
My LANG environment variable is set to en_GB.UTF-8, consistent with /etc/locale, which is the standard way to configure the charset on a Linux desktop AFAIK, so shouldn't glib read it from that?
#include <glib.h>
int main()
{
const char *charset = NULL;
gboolean utf = g_get_charset(&charset);
g_print("Charset is '%s' (%sUTF)\n", charset, utf ? "" : "not ");
return 0;
}