Re: g_utf16_to_utf8
- From: Fabrício Godoy <skarllot gmail com>
- To: Hubert Figuiere <hub figuiere net>
- Cc: gtkmm-list gnome org
- Subject: Re: g_utf16_to_utf8
- Date: Fri, 17 Apr 2009 16:45:09 -0300
2009/4/17 Hubert Figuiere
<hub figuiere net>
On 04/17/2009 03:20 PM, Fabrício Godoy wrote:
Glib::ustring accepts a "gchar*" but not a gchar wrapped by RefPtr.
Did you read the documentation of Glib::RefPtr<>?
What didn't you understand in the part that say:
"RefPtr<> can store any class that has reference() and unreference() methods. In gtkmm, that is anything derived from Glib::ObjectBase, such as Gdk::Pixmap."
Yes, I've read this, but I don't understood right. Please sorry.
win_NetworkInterface class is a specialization of NetworkInterface abstract
class.
The NetworkInterface class defines "get_name" to return "Glib::ustring".
And I want to keep this as is, to enjoy ustring facilities.
And? I never say don't use Glib::ustring. I just say to free you pointer using g_free() as told in the documentation.
Oh, below code worked well.
I thought (past of think?) that freeing the pointer, the ustring becomes to point to garbage.
The code below is right?
Glib::ustring win_NetworkInterface::get_name()
{
gchar* pt_name = g_utf16_to_utf8(
(gunichar2*) this->ifinfo.FriendlyName, -1, NULL, NULL, NULL);
Glib::ustring name(pt_name);
g_free(pt_name);
return name;
}
Thank you very much.
Hub
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]