En attendant UTF8

Une application correctement internationalisée ne doit pas faire de suppositions sur le nombre d'octets par caractère. Cela signifie que vous ne devez pas faire d'arithmétique de pointeurs pour cheminer parmi les caractères d'une chaîne ; cela signifie aussi que vous ne devez pas vous servir d'objets std::string ou de fonctions C standard telles que strlen() car elle se fondent sur de telles suppositions pour effectuer leurs calculs.

Même si vous avez certainement déjà délaissé les tableaux de char* vides et l'arithmétique des pointeurs en vous servant de std::string, vous devez maintenant utiliser à la place des objets Glib::ustring. Voyez le chapitre concernant les Glib::ustring dans les Fondamentaux.

XXV.III.I. Glib::ustring et 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::locale::global(std::locale("")); // Set the global locale to the user's preferred locale.
                                      // Usually unnecessary here, because Glib::init()
                                      // or Gtk::Application::create() does it for you.
std::ostringstream output;
output << percentage << " % done";
label->set_text(Glib::locale_to_utf8(output.str()));