Re: locale_to_utf8 crashes on WinXP with Gtkmm 2.8.4 / Glibmm 2.8.6 and Gtk+ 2.8.18 / Glib 2.10.3



On Saturday 03 June 2006 12:19 am, Vinzenz 'evilissimo' Feenstra wrote:
> Hi,
>
> I'm trying to use a string with german umlauts in an application and
> Glib::locale_to_utf8 returns an invalid string.
> If I execute this:
>
> Glib::ustring test = Glib::locale_to_utf8("äöüß");
>
> and I retrieve an  invalid object Glib::ustring the debugger shows me an
> Bad Pointer in this object.
>
> I'm wondering if this _can_ be a Glibmm problem or if it is more a Glib
> problem?
>
> Btw anyone knows another GTK+ package like this one from gladewin32.sf.net?

It is very bad practice to call Glib::locale_to_utf8() on a string literal 
because it will only work if the codeset locale on the machine on which the 
code is compiled is the same as the codeset in which the string literal 
happens to have been written.  These may not even be the same if the code is 
written and compiled on the same machine (it will depend on the editor with 
which the code is being written).

If you want a string literal to be in UTF8 then write it in UTF8, or write it 
in some other known codeset and use codeset conversion which does not base 
itself on the locale.

Chris.





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