Andrew J. Brehm
Andrew J. Brehm

Reputation: 4758

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, depending on the library used).

So how are Strings passed to GTK+ widgets?

(I am thinking C Strings, but I want to know for sure.)

Upvotes: 1

Views: 1671

Answers (2)

Stephen Gentle
Stephen Gentle

Reputation: 21

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.

Upvotes: 2

unwind
unwind

Reputation: 399863

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.

Upvotes: 6

Related Questions