g_locale_from_utf8() errors on Windows 2000



Hi all,

I'm getting an error when using g_locale_from_utf8()
under win2000 (doesn't happen in XP or Vista).

With a locale of "English_United States.1252", for:
---------------------------------------------------------
GError* error = 0;
gsize written = 0;
g_locale_from_utf8("hello", 5, NULL, &written, &error);
---------------------------------------------------------

I get:
---------------------------------------------------------
Invalid byte sequence in conversion input
---------------------------------------------------------
in error->message.

A simple test case is attached.

This gets especially annoying when using Glibmm,
where a simple
std::cout << Glib::ustring("abc");
triggers a conversion error exception (it calls the
g_locale_from_utf8() function), and the program dies
all over the place due to unhandled exceptions.

The gtk/glib/dependencies come from
http://ftp.gnome.org/pub/gnome/binaries/win32/


Thanks,
Alexander
#include <gtk/gtk.h>
#include <stdio.h>
#include <locale.h>

/*
Compile with:
gcc `pkg-config --cflags --libs gtk+-2.0` test_win2k_locale.c -o test_win2k_locale

The output of this program under win2k is:
--------------------------------------------------------------
Current locale: English_United States.1252
Invalid byte sequence in conversion input
--------------------------------------------------------------
*/

int main(int argc, char** argv)
{
	gtk_init(&argc, &argv);

	fprintf(stderr, "Current locale: %s\n", setlocale(LC_ALL, NULL));

	GError* error = 0;
	gsize written = 0;
	g_locale_from_utf8("hello", 5, NULL, &written, &error);

	if (error) {
		fprintf(stderr, "%s\n", error->message);
	}

	return 0;
}




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]