Re: Can't write ustring to std::cout [Was: Re: string problems]



On Fri, 2007-10-05 at 16:45 +0200, Philipp Klaus Krause wrote:
> Murray Cumming schrieb:
> 
> >> std::string linetmp;
> >> std::getline(source, linetmp);
> >> line = linetmp;
> >> linetmp = line;
> >> std::cout << linetmp << "\n";
> >>
> >> works,
> >>
> >> std::string linetmp;
> >> std::getline(source, linetmp);
> >> line = linetmp;
> >> linetmp = line;
> >> std::cout << line << "\n";
> >>
> >> still doesn't.
> > 
> > I believe that this is relevant:
> > http://www.gtkmm.org/docs/glibmm-2.4/docs/reference/html/classGlib_1_1ustring.html#_details
> > (see "Glib::ustring and stream input/output")
> > 
> > I think you need to know what encoding your string has, and convert it
> > when appropriate. You should also catch exceptions for when this fails.
> > 
> 
> std::string linetmp;
> std::getline(source, linetmp);
> line = Glib::locale_to_utf8(linetmp);
> std::cout << line << "\n";
> 
> fails in the call to Glib::locale_to_utf8.
> here's the output of locale:
> LANG=de_DE.UTF-8
> LC_CTYPE="de_DE.UTF-8"
> LC_NUMERIC="de_DE.UTF-8"
> LC_TIME="de_DE.UTF-8"
> LC_COLLATE="de_DE.UTF-8"
> LC_MONETARY="de_DE.UTF-8"
> LC_MESSAGES="de_DE.UTF-8"
> LC_PAPER="de_DE.UTF-8"
> LC_NAME="de_DE.UTF-8"
> LC_ADDRESS="de_DE.UTF-8"
> LC_TELEPHONE="de_DE.UTF-8"
> LC_MEASUREMENT="de_DE.UTF-8"
> LC_IDENTIFICATION="de_DE.UTF-8"
> LC_ALL=
> 
> So everything should be UTF-8 (I can display the file with the
> problematic line ";add	𝔐, v1, v2" with cat, edit it in gedit, etc).

I guess it's not in locale encoding. What does the exception message
say? Note that I see a square in that string in Evolution. 

-- 
murrayc murrayc com
www.murrayc.com
www.openismus.com




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