Re: Handling utf8 data from SQLite



> Why not catch the exception and print it out to find out?

To be honest I don't know how to do this but will try to see if I can
work it out.

>
> Probably the conversion of utf-8 to the locale encoding done behind the
> scenes by the overloaded operator<<() for Glib::ustring is throwing.
> That in turn could be because the the input string is not in utf-8, or

If I declare a string as Glib::ustring does this mean it is in utf8?
Both username and password are declared as Glib::ustrings

> because you have not called std::locale::global(std::locale("")) to set
> the locale.

Yep I definitely haven't called this.  This should be put in main yeah
when first starting the program?

> More generally, unless you want to manipulate utf-8 in your strings by
> using Glib::ustring's specific utf-8 reliant methods, you are better off
> avoiding problems like this by using std::string.  More specifically,

Not sure if I do at this stage, mainly just the retrieval and display
but will want the flexibility there in the future so sticking with
Glib::ustring is probably the way to go.

> if you do want to use utf-8 reliant methods but done want conversion to
> occur with operator <<(), then do:
>
> std::cout << "DB - Password: " << password.raw() << std::endl;
>

Thanks for this!  Using raw() avoids the error until I learn the
exception catching stuff.


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