Re: ustring::compose and win32



Le jeudi 19 mai 2011 à 18:32 +0100, Robert Pearce a écrit :
> Hi Bastien,
> 
> On Thu, 19 May 2011 17:55:22 +0200 you wrote:
> > 
> > This is a runtime exception.
> > A Glib::ConvertError with this message : "La conversion du jeu de
> > caractères « WCHAR_T » vers « UTF-8 » n'est pas prise en charge" in
> > what().
> 
> Windows (since 2K-pro) uses UTF-16 "wide" characters internally,
> because it allows more languages to be supported than traditional ASCII
> and is less chaotic than the multitude of "code pages" that Win9x
> needed. However it's not ASCII compatible, unlike UTF-8. Gtk uses UTF-8
> because it's the world-wide standard for doing it right.
> 
> > 
> > I attached a sample. Throws at line 7 under windows, works under Linux.
> 
> Linux doesn't use stupid wide characters - it has something vaguely
> like code pages but all modern distros support UTF-8. So Gtk never has
> to try converting from an incompatible WCHAR_T type.
> 
> Now, it should be possible to do the WCHAR_T to UTF-8 conversion and
> the Windows port of GTK should support it, but you may not have
> everything you need installed. And at that point my knowledge hits a
> limit, since I don't do Windows.
> 
> Cheers,
> Rob
I know that, but I cannot figure why an integer-to-string conversion
inside ustring fails: there's nothing to do with the OS.
I use UTF-8 anywhere in the program, loading data from an UTF-8
database, and it renders well ; including the π or ™ characters.

I digged into source code, and saw ustring::compose uses
std::wostringstream (as GLIBMM_HAVE_WIDE_STREAM is defined) to
"stringify" parameters, and then uses g_utf16_to_utf8 or g_convert to
convert data back to UTF-8.
g_convert is used as SIZEOF_WCHAR_T seams not to be defined.

g_utf16_to_utf8 works (out-of-the box), but not g_convert("UTF-8",
"WCHAR_T").

The question is now : "how to make g_convert work?"

-- 
Bastien Durel



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