Re: std::cout << Glib::ustring(utf8_literal) throws exception



Then i guess you would somehow need to set an UTF-8 locale (setting LC_ALL to 0 you set the C or (i think) ANSI X3.4-1986 locale).

2008/7/13 Sohail Somani <sohail taggedtype net>:
Yes, you are right. Copying the ustring to a std::string gets rid of the error but still doesn't work right because it is interpreted as ASCII in the console.

Milosz Derezynski wrote:
It should be noted here that Glib::ustring::operator<< performs a conversion from UTF-8 to the currenty set locale (yeah it's weird and unexpected) and thus works intransparent and produces sideeffects; i don't know the implication of this on Windows but i'm willing to be that that's the reason for your problem here. You could try copying the ustring to an std::string before using << and then feed the std::string to cout.

2008/7/13 Sohail Somani <sohail taggedtype net <mailto:sohail taggedtype net>>:


   Hi,

   The following code works fine on Linux but dies on Windows when run
   in the console:

   #include <gtkmm.h>

   int main()
   {
    setlocale(LC_ALL,0);
    // Should output aleph
    std::cout << Glib::ustring("\xd7\x90") << std::endl
   }

   The error is: "Invalid byte sequence in conversion input"

   Has anyone tried UTF-8 with Glib on Windows? What else do I need to do?

   Thanks,

   Sohail

   _______________________________________________
   gtkmm-list mailing list
   gtkmm-list gnome org <mailto:gtkmm-list gnome org>

   http://mail.gnome.org/mailman/listinfo/gtkmm-list




--
------------
Please note that according to the German law on data retention,
information on every electronic information exchange with me is
retained for a period of six months.
[Bitte beachten Sie, dass dem Gesetz zur Vorratsdatenspeicherung zufolge
jeder elektronische Kontakt mit mir sechs Monate lang gespeichert wird.]


------------------------------------------------------------------------


_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list


--
Sohail Somani
http://uint32t.blogspot.com



--
------------
Please note that according to the German law on data retention,
information on every electronic information exchange with me is
retained for a period of six months.
[Bitte beachten Sie, dass dem Gesetz zur Vorratsdatenspeicherung zufolge
jeder elektronische Kontakt mit mir sechs Monate lang gespeichert wird.]

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