outputting non-ASCII string problem
- From: Gezim Hoxha <gezimetc shaw ca>
- To: post gtkmm list <gtkmm-list gnome org>
- Subject: outputting non-ASCII string problem
- Date: Thu, 15 Mar 2007 01:18:17 -0600
Hi all,
I have a function that reads a file that contains some ISO-8859-1
encoded characters:
bool Locations::loadData(const Glib::ustring& file)
{
Glib::RefPtr<Glib::IOChannel> skeda = Glib::IOChannel::create_from_file
(file, "r");
std::cout << "Encoding is " << skeda->get_encoding() << std::endl;
skeda->set_encoding("ISO-8859-1");
std::cout << "New encoding is " << skeda->get_encoding() << std::endl;
Glib::ustring line;
int i=0;
try
{
while ((skeda->read_line(line)) == Glib::IO_STATUS_NORMAL)
{
std::cout << "Initration: " << i << std::endl << std::flush;
ctrs.push_back(line); // ctrs is a Glib::ustring vector
std::cout << line << std::endl;
++i;
}
}
catch (Glib::Exception& e)
{
std::cout << "Something happended I supposed: " << typeid(e).name() <<
" and " << e.what() << std::endl;
}
return true;
}
And I've isolated the problem to be with outputting the string "line"
namely in:
std::cout << line << std::endl;
When a line such as the following is attempted to be printed with the
above statement:
ad,anyos,Any�5,42.5333333,1.5333333
This exception is thrown:
N4Glib12ConvertErrorE with this what:
Invalid byte sequence in conversion input
So, how am I supposed to print those types of lines?
Thanks,
-Gezim
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]