Glib::ustring in utf8 to std::wstring
- From: Filipe Apostolo <f apostolo cbr gmail com>
- To: gtkmm-list gnome org
- Subject: Glib::ustring in utf8 to std::wstring
- Date: Wed, 20 May 2009 10:42:17 +0100
Hi to all,
I'm facing a problem that consists to go back to the previous encodding.
I'm workin in windows and with DCOM objects. Those DCOM Objects works
with wchar parameters.
So if I' want to list in a Gtk::TreeView the names of the available DCOM
servers (for example) I'Need to convert the names from std::wstring to
Glib::ustring and convert to utf8 to show characters like 'ç', ã, ..
For this task I do it like this:
*********
std::wstring origin = source_str;
std::string equivalentStr;
equivalentStr.assign(origin_wstr.begin(), origin_wstr.end());
Glib::ustring ustr= Glib::locale_to_utf8 (origin);
Then ..
row[mColumModel.name] = ustr;
*********
with this steps If I heave a Name like 'Renovação'
In the treeview It apears has it should.
But when user select this row and I wan't to convert it again to wstring
It trims the string like 'Renova';
The back convertion I do it in this way:
*************
std::string str = Glib::locale_from_utf8 (ustr);
std::wstring convertedWStr (str.length(),L' ');
std::copy(str.begin(),
str.end(),
convertedWStr.begin());
*************
Thanks in advance;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]