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



Dnia Fri, 05 Oct 2007 17:03:35 +0200
Philipp Klaus Krause <pkk spth de> napisał(a):

> Murray Cumming schrieb:
> 
> >> 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?
> 
> "Invalid byte sequence in conversion input"
> 

#include <locale>

and then before getline()
setlocale(LC_ALL, "");




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