GNOME Bugzilla – Bug 543789
g_iconv failure on win9x
Last modified: 2008-07-21 17:02:13 UTC
Please describe the problem: Windows 98, MSVC 6 compiler. Using the program below gives correct results for glib 2.12 (gnu iconv) and incorrect glib 2.16.X (win_iconv). File: testme.c -------------- int main (int argc, char* argv[]) { GIConv giconv; GError *error = 0; gchar* out; char* from_codeset = argv[1]; char* to_codeset = argv[2]; giconv = g_iconv_open (to_codeset, from_codeset); if (giconv == (GIConv) -1) { printf ("g_iconv_open error\n"); return 0; } out = g_convert_with_iconv ("A", 1, giconv, 0, 0, &error); if (error && error->code == G_CONVERT_ERROR_ILLEGAL_SEQUENCE) { printf ("Illegal sequence\n"); return 0; } g_iconv_close (giconv); printf ("Successful conversion: %s\n", out); return 0; } Output for glib 2.12: --------------------- C:\Program Files\Streamripper>d:testme CP1252 UTF-8 Successful conversion: A C:\Program Files\Streamripper>d:testme UTF-8 CP1252 Successful conversion: A C:\Program Files\Streamripper>d:testme UTF-8 US-ASCII Successful conversion: A For glib 2.16: --------------------- C:\Program Files\Streamripper>d:testme CP1252 UTF-8 Successful conversion: A C:\Program Files\Streamripper>d:testme UTF-8 CP1252 Illegal sequence C:\Program Files\Streamripper>d:testme UTF-8 US-ASCII g_iconv_open error In addition, the glib implementation of win_iconv has disabled the ability to workaround by using gnu iconv through use of WINICONV_LIBICONV_DLL environment variable. The only workaround I can find is to go back to using iconv() directly. Steps to reproduce: 1. 2. 3. Actual results: Expected results: Does this happen every time? yes Other information:
GLib 2.16 is not supposed to even work on Windows 98, I am a bit amazed that you manage to run your test program on it. Most likely any program that would use a more realistic set of GLib APIs would fail badly. (Your test case works fine on XP compiled with either gcc or MSVC6.) > the glib implementation of win_iconv has disabled the ability > to workaround by using gnu iconv through use of WINICONV_LIBICONV_DLL Well, I would say "hasn't enabled" instead of "disabled", but yes. I don't see the need for it. (Given that GLib 2.16 is not even supposed to work on Windows 9x, for instance.)
I saw the note about windows 98 on the web site, but I thought that only applies to gtk+. I am only using glib. Can you explain why you think windows 98 would not work? For example, which sections of glib would rely on win32 calls not implemented in win98? I have been using it for a while, and didn't encounter any problems until now.
> Can you explain why you think windows 98 would not work? Because GLib explicitly uses the wide character versions of many APIs that isn't supported on Win9x. No attempts at all have been made to keep it working on Win9x since 2.8 or so. If it works to some extent, that is just coincidental. > didn't encounter any problems until now. You were just lucky then.
Sorry, I misremembered: It is from 2.14 that GLib uses just the wide-character APIs. So if you stick to 2.12, that should then work on Win9x.
Thanks so much for the information. As you indicated, I was trying to upgrade from 2.12 to 2.16 when I found this problem. I guess I'm in a bit of a bad situation now. One of the reasons I chose glib was its good compatibility. If you would consider anything I can help to restore win98 to glib, please think it over and let me know. Continuing with glib would be my preferred option. -Greg
You could backport the new functionality (or bug fixes) in 2.16 that you need to 2.12 and build it yourself...?
Yes, I think I will try building a custom version, as you suggest. Thanks.