Re: Handling utf8 data from SQLite
- From: Chris Vine <chris cvine freeserve co uk>
- To: Zettai Muri <zettaimuri gmail com>
- Cc: gtkmm-list gnome org
- Subject: Re: Handling utf8 data from SQLite
- Date: Sat, 10 Sep 2011 12:44:43 +0100
On Sat, 10 Sep 2011 10:11:47 +1000
Zettai Muri <zettaimuri gmail com> wrote:
> > sqlite3_finalize(stmt);
> > sqlite3_close(db);
> > std::cout << "DB - Password: " << password << std::endl;
> > return password;
> The strangest part of this is that if I comment out:
> std::cout << "DB - Password: " << password << std::endl;
> Recompile it and run it. All combinations of Japanese/English
> usernames to passwords can be searched for and returned (displayed on
> label) without producing the 'unhandled exception in signal handler'
> Does anyone know why just this line could cause this?
Why not catch the exception and print it out to find 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
because you have not called std::locale::global(std::locale("")) to set
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,
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;
] [Thread Prev