C++, GTK+, and String types
Excuse my ignorance here but I know neither C++ nor GTK+.
Which String type is used when setting Strings in GTK+ widgets?
In .NET, Strings passed to a control are obviously .NET System.String. In Cocoa, Strings passed to a control are NSString. But I understand C++ does not have a standardized String type (but indeed several, dependin开发者_JS百科g on the library used).
So how are Strings passed to GTK+ widgets?
(I am thinking C Strings, but I want to know for sure.)
All text in GTK+ is UTF-8-encoded, using char *
, of course const
where possible. Remember that GTK+ is implemented in C, so there is no use of STL for instance.
The underlying glib's character-set conversion documentation begins by stating:
Glib uses UTF-8 for its strings, and GUI toolkits like GTK+ that use Glib do the same thing.
Note that if you are using Gtk+ in C++, even though it's possible to use the native C interface, you definitely should be using Gtkmm, the native C++ binding instead. It's a far better interface, as you don't have to mess with any GObject code.
精彩评论