Am 13.02.2013 17:55, schrieb ×××××× ×××××: > Can I use std::u16string, std::u32string or std::string (with u8 string > literals) with gettext and get perfect UTF-8 i18n-alized strings just > like I would get by using Glib::ustring and gettext (including > glibmm/i18n.h in source files and mark string with _("...") macro)? > I'd be interested in knowing this, too. > If I can, there's one problem left: is it possible/fast enough/easy > enough to convert the strings to Glib::ustring every time I need to pass > them to the GUI (i.e. every time my data changes and I need to update > the GUI, or the GUI gets rendered for a GUI specific reason, i.e. a > window being hidden and then shown again)? > If you use std::strings, I don't see a problem. You are not so much converting an std::string to a ustring as wrapping them. If you look at the source code you see that the ustring(const std::string&) constructor does nothing more than invoking the copy constructor on std::string. Up until now this was a very fast operation because std::string was copy-on-write. AFAIK this is about to change in favor of short string optimization (see [1]). Even then it should be reasonably fast for smaller strings. Move constructors will ultimately remove the performance issue again. > I'll happily use C++11 strings, but it may be easier to use > Glib::ustring directly, instead of converting strings (I don't really > gain much from the move constructor, it's just a little speed gain when > reading the document data from file and writing into the C++ objects > representing the document data. It's more a design issue: write the code > so that later later I'll need minimal changes to adapt to new features. > And get the move constuctor benefits (and other C++11 features) without > effort) > > Anatoly Krasner > > P.S. I want to handle all languages, using gettext. But how did you know > my local language is hebrew? Hmmm... *thinking: where did I mention my > nationality/language? Oh, probably while registering to the mailing > list* > I guess the hebrew letters in your "From"-line gave it away. [1] http://scottmeyers.blogspot.de/2012/04/stdstring-sso-and-move-semantics.html Regards, Florian Philipp
Attachment:
signature.asc
Description: OpenPGP digital signature