Re: [[gtkmm] Problem with std::string -> Glib::ustring conversion]



Hi Brian!

Brian Gartner wrote:

My questions, then, are:

1) Is it possible to simply specify that a string must be converted from
e.g. ISO 8859-1, including the characters with values > 127, into UTF-8? I
thought that this was what locale_to_utf8 would do, but if so I'm doing
something wrong, as my program crashed when I called it on strings
containing characters with values > 127.


I've successfully used

Glib::ustring = Glib::convert(std::string source_text, "UTF-8", source_encoding)

for rather massive amounts of obscure inputs without a glitch, so that should work. Use 'iconv -l' to list available encodings.

Beware that some Linux systems use UTF-8 as their default system locale encoding. Just a guess, but that might cause the problems you're seeing with locale_to_utf8(). What's the output of the 'locale' command?

--
Christer Palm




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