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ós,05,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

_______________________________________________
gtkmm-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Reply via email to