Re: [[gtkmm] Problem with std::string -> Glib::ustring conversion]



Thanks everyone; you've all been very helpful. I'd have tried these
suggestions and responded sooner, but I've been away from home (and my
computer) the past few days.

Again, thank you all,

Brian Gartner

On Sun, 14 Sep 2003, joey yandle wrote:

> > 
> > 1) Is it possible to simply specify that a string must be converted from
> > e.g. ISO 8859-1, including the characters with values > 127, into UTF-8? I
> > thought that this was what locale_to_utf8 would do, but if so I'm doing
> > something wrong, as my program crashed when I called it on strings
> > containing characters with values > 127.
> > 
> 
> Yes... here's a code snippet:
> 
>         std::string charset = "ISO-8859-1";  
>         std::string data = read_from_file();
>         Glib::ustring ret;
>         try {
>             ret = Glib::convert(data, "UTF-8", charset);
>         } catch(Glib::Exception& e) {
>             ret = data;
>             Glib::ustring::iterator i;
>             while(!ret.validate(i)) { 
>                 ret.replace(i++, i, "*");
>             }
>         }
> 
> cheers,
> --
> joey yandle                   ___====-_  _-====___
> www.divisionbyzero.com  _--~~~#####//      \\#####~~~--_
> /jwy/pubkey.asc      _-~##########// (    ) \\##########~-_
>                     -############//  :\^^/:  \\############-
>                   _~############//   (@::@)   \\############~_
>                  ~#############((     \\//     ))#############~
>                 -###############\\    (^^)    //###############-
>                -#################\\  / "" \  //#################-
>               -###################\\/      \//###################-
>              _#/:##########/\######(   /\   )######/\##########:\#_
>              :/ :#/\#/\#/\/  \#/\##\  :  :  /##/\#/  \/\#/\#/\#: \:
>              "  :/  V  V  "   V  \#\: :  : :/#/  V   "  V  V  \:  "
>                 "   "  "      "   \ : :  : : /   "      "  "   "
> 
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
> 




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