Αναμένεται UTF8

Μια σωστά διεθνοποιημένη εφαρμογή δεν θα κάνει υποθέσεις για τον αριθμό των ψηφιολέξεων σε έναν χαρακτήρα. Αυτό σημαίνει ότι δεν πρέπει να χρησιμοποιείτε αριθμητικό δείκτη για να περιδιαβείτε τους χαρακτήρες σε μια συμβολοσειρά και σημαίνει ότι δεν πρέπει να χρησιμοποιήσετε std::string ή τυπικές συναρτήσεις C όπως strlen(), επειδή κάνουν την ίδια υπόθεση.

Όμως, προφανώς αποφεύγετε ήδη γυμνούς πίνακες char* και αριθμητικούς δείκτες χρησιμοποιώντας την std::string, έτσι χρειάζεστε μόνο να ξεκινήσετε χρησιμοποιώντας στη θέση τους Glib::ustring. Δείτε το κεφάλαιο Βασικά για την Glib::ustring.

27.3.1. Glib::ustring and std::iostreams

Unfortunately, the integration with the standard iostreams is not completely foolproof. gtkmm converts Glib::ustrings to a locale-specific encoding (which usually is not UTF-8) if you output them to an ostream with operator<<. Likewise, retrieving Glib::ustrings from istream with operator>> causes a conversion in the opposite direction. But this scheme breaks down if you go through a std::string, e.g. by inputting text from a stream to a std::string and then implicitly converting it to a Glib::ustring. If the string contained non-ASCII characters and the current locale is not UTF-8 encoded, the result is a corrupted Glib::ustring. You can work around this with a manual conversion. For instance, to retrieve the std::string from a ostringstream:

std::ostringstream output;
output.imbue(std::locale("")); // use the user's locale for this stream
output << percentage << " % done";
label->set_text(Glib::locale_to_utf8(output.str()));