Re: std::cout << Glib::ustring(utf8_literal) throws exception
- From: Chris Vine <chris cvine freeserve co uk>
- To: Sohail Somani <sohail taggedtype net>
- Cc: gtkmm-list gnome org
- Subject: Re: std::cout << Glib::ustring(utf8_literal) throws exception
- Date: Sun, 13 Jul 2008 22:50:39 +0100
On Sun, 13 Jul 2008 10:01:02 -0700
Sohail Somani <sohail taggedtype net> wrote:
> But yes, I need to figure out why the conversion is failing in the
> first place rather than trying these hacks (ustring -> std::string).
Conversions can fail for various reasons, but to start from the
beginning have you set a locale of any kind which handles non-ascii
characters? In particular, have you called setlocale(LC_ALL,""), or the
equivalent std::locale::global(std::locale(""))? If you have not, the
C locale will be used and any glibmm conversion will throw an exception
if a byte of value >= 128 is met.
Incidentally, you don't need to make a std::string object, you can
access the one in the Glib::ustring object with Glib::ustring::raw().
(However, there was no need to use a Glib::ustring object at all in the
example you originally gave, but probably it was just a cut-down
example of something else.)
Chris
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]